From: Daniel A. S. <st...@ic...> - 2005-04-22 06:22:23
|
Zoran, sorry for the delay On Sunday, Apr 17, 2005, at 17:33 Australia/Sydney, Zoran Vasiljevic wrote: > > Am 17.04.2005 um 01:58 schrieb Daniel A. Steffen: > >> IMO the ideal strategy should be to return errors in case of a load >> failure, but if the load succeeds to reset the interp to clean any >> unneeded messages about missing optional symbols, the correct place >> for that would be in Tcl_LoadObjCmd() after the call to TclLoadFile, >> c.f. patch below. >> > > I did already put Tcl_ResetResult in TclLoadFile() if the call > is about to return success. It is checked in the head yesterday. the issue with your placement of Tcl_ResetResult()s in TclLoadFile() as opposed to mine in Tcl_LoadObjCmd() is the following: it is not possible to completely determine in TclLoadFile() wether a [load] will succeed or not, so ideally the interp should only be reset once Tcl_LoadObjCmd() has checked that the _Init proc has been found; otherwise OS error info will be lost: As mentioned, for dyld, link errors e.g. due to missing library dependencies can only be determined in TclpFindSymbol(), i.e. TclpDlopen() of such a library will succeed, but TclpFindSymbol() will fail and add an error message to the interp. With your current changes, such link error messages will be reset before the the check for _Init proc resolution in Tcl_LoadObjCmd() returns TCL_ERROR, so [load] will fail but the OS error message will be lost... This is why I proposed in my last mail to only reset the interp in Tcl_LoadObjCmd() after the _Init check: > Index: generic/tclLoad.c > =================================================================== > RCS file: /cvsroot/tcl/tcl/generic/tclLoad.c,v > retrieving revision 1.13 > diff -u -p -r1.13 tclLoad.c > --- generic/tclLoad.c 9 Mar 2004 12:59:05 -0000 1.13 > +++ generic/tclLoad.c 16 Apr 2005 23:52:47 -0000 > @@ -385,6 +385,7 @@ Tcl_LoadObjCmd(dummy, interp, objc, objv > code = TCL_ERROR; > goto done; > } > + Tcl_ResetResult(interp); > > /* > * Create a new record to describe this package. I realize that this would mean that TclLoadFile/Tcl_FSLoadFile can return TCL_OK with an error message present in the interp, which is undesirable, the only direct way around this that I can see would be to move the check that the first symbol was successfully looked up from Tcl_LoadObjCmd() into TclLoadFile(), but that does not seem correct either... Maybe the right way to solve this issue would be to add an API to retrieve load error messages out of band from a Tcl_LoadHandle*? with this, Tcl_LoadObjCmd() could return OS error info once it has determined that _Init was not found? Cheers, Daniel -- ** Daniel A. Steffen ** "And now for something completely ** Dept. of Mathematics ** different" Monty Python ** Macquarie University ** <mailto:st...@ma...> ** NSW 2109 Australia ** <http://www.maths.mq.edu.au/~steffen/> |