| Ticket UUID: | 3216070 | ||
| Title: | Loading extension libraries from embedded Tcl applications | ||
| Type: | Bug | Created on: | 2011-03-16 11:37:48 |
| Submitter: | mxmanghi | Assigned to: | nijtmans |
| Subsystem: | 40. Dynamic Loading | Severity: | |
| Priority: | 5 Medium | Last modified: | 2011-03-25 01:38:32 |
| Status: | Closed | Closed by: | nijtmans |
| Resolution: | Fixed | Closed on: | 2011-03-22 15:12:04 |
| Version: | obsolete: 8.5.9 | ||
| Description: | ||||
Shared libraries providing Tcl extensions are loaded for the Unix family by the code in tclLoadDl.c, which interfaces Tcl with the dlopen(<library_path>,flags) system call. Tcl chose to set dlopen's flags argument as RTLD_NOW | RTDL_GLOBAL. Globally loading the extension symbols was found to crash an application (Apache Rivet) that embeds a Tcl interpreter, which in turn gains access to a subset of the application commands by loading an extension library. The application successfully loads the library by calling Tcl_PkgRequire, but crashes shortly after in a function unrelated to the extension library. Replacing Tcl_PkgRequire with a direct call to dlopen and passing RTLD_NOW | RTLD_LOCAL as second argument restores mod_rivet (and Apache) full functionality. On the other hand, it was also verified that setting in tclLoadDl.c the flags argument as RTLD_NOW | RTLD_LOCAL and building a custom Tcl installation against which Rivet gets linked, preserves Apache functioning even when the extension is loaded by calling Tcl_PkgRequire, thus fully identifying the problem with the RTLD_GLOBAL flag. | ||||
| User Comments: | ||||
nijtmans added on 2011-03-16 19:26:42:
File Added - 404492: 3216070.patch nijtmans added on 2011-03-22 22:12:04:
allow_comments - 1 See discussion about this among TCT members: <https://sourceforge.net/mailarchive/message.php?msg_id=27211924> Conclusion: dlopen should use: (RTLD_NOW|RTLD_LOCAL) If this causes problems for anyone, please report this, there sure is another solution without breaking applications that embed Tcl (that's what this issue is about....). Fixed on trunk and core-8-5-branch. Untouched on core-8-4-branch. andreas_kupries added on 2011-03-25 01:38:32:
Note for people getting tripped by the reintroduced bug #1961211, notably on Darwin, i.e. OS X. If your library is linked using -flat_namespace and fails to load with a message like dyld: Symbol not found: ... Referenced from: ... Expected in: flat namespace Trace/BPT trap then this option has to be removed, and a possibly present -undefined suppress|warning as well, to make the library loadable again. This happened for Metakit. | ||||
Attachments:
- 3216070.patch [download] added by nijtmans on 2011-03-16 19:26:42. [details]
