Artifacts Associated With Ticket 960414ffffffffffffffffffffffffffffffffff
Ticket change [04d0a1fc76] (rid 88939) by tmh on 2004-05-25 21:13:47:
- assignee initialized to: "dkf"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Something has changed in the exit handling of Tcl since the 8.4.6 release. This change causes a segmentation violation when using the Oratcl extension. This is similar to a previous Bug ID # 2560. At issue is that the Oracle library (that cannot be changed) that is linked dynamically at runtime with Oratcl, has atexit() calls embedded in the library. These calls fire when tcl finally calls exit(). If the Oratcl extension library is unloaded before the exit() happens, then the atexit() can no longer reference the symbols in the Oratcl library that called the oracle library. I am listing this as a Tcl Bug because, Oratcl has not been changed. This works just fine in Tcl 8.4.6. jumpgate: [75] > gdb /opt/tcl8.5a2d/bin/tclsh8.5 GNU gdb 4.18 Copyright 1998 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "sparc-sun-solaris2.7"... (gdb) run Starting program: /opt/tcl8.5a2d/bin/tclsh8.5 % package require Oratcl 4.2 % set lda [oralogon t/b@c] oralogon: invalid username/password; logon denied % exit Program received signal SIGSEGV, Segmentation fault. Cannot access memory at address 0xfe842e54. Maybe there is a way to preserve the library so that it is not unloaded, but I cannot tell from the documentation how to do that. Also, Oratcl does use an exit handler. If I add an exit(0) to my exit handler, the core dump goes away, but none of the other things in Tcl_Finalize occur.
- foundin initialized to: "obsolete: 8.5a2"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "tmh"
- subsystem initialized to: "16. Commands A-H"
- title initialized to:
exit causes segmentation violation with Oratcl extension
- type initialized to: "Bug"
Ticket change [6146473df8] (rid 92214) by dkf on 2004-05-26 04:33:17:
- assignee changed to: "hobbs"
Ticket change [02cf90d7d3] (rid 119713) by mistachkin on 2004-05-26 04:38:48:
- icomment:
Logged In: YES user_id=113501 Are you simply exiting tclsh or is your application calling one of the Tcl C API functions, if so, which one? As long as Tcl_SetExitProc is never called with a non-NULL pointer, the new exit handling from TIP #121 should not have any effect. Is Tcl_Finalize actually being called? If it is, then Tcl is using the default exit handling and the bug may be in Tcl_Finalize itself.
- login: "mistachkin"
- mimetype: "text/plain"
- username: "mistachkin"
- icomment:
Ticket change [cfd70586b9] (rid 113059) by tmh on 2004-05-26 04:55:22:
- icomment:
Logged In: YES user_id=92123 in the init area. Tcl_CreateExitHandler ((Tcl_ExitProc *) Oratcl_Exit, (ClientData) OratclStatePtr); void Oratcl_Exit (clientData) ClientData clientData; { Oratcl_Clean(clientData); Tcl_DecrRefCount(OMV_null); Tcl_DecrRefCount(OMV_zero); } /* callback - clean up procs left open on interpreter deletetion */ Tcl_CallWhenDeleted(interp, (Tcl_InterpDeleteProc *) Oratcl_Delete, (ClientData) OratclStatePtr); More to the point. If I comment out all exit handling from the Oratcl code. (It's just memory leaks after all :) I still get the seg fault on exit. Todd Also there is a interp delete callback for slave interps. - login: "tmh"
- mimetype: "text/plain"
- username: "tmh"
- icomment:
Ticket change [3eaf565643] (rid 121314) by mistachkin on 2004-05-26 08:06:00:
- icomment:
Logged In: YES user_id=113501 What line in the Tcl core actually causes the segfault (especially, is it inside of Tcl_Finalize)? Is your exit handler actually being called (when it's not commented out, that is)? Do you have a stack trace?
- login: "mistachkin"
- mimetype: "text/plain"
- username: "mistachkin"
- icomment:
Ticket change [bc7419790d] (rid 101751) by tmh on 2004-05-26 10:50:29:
- icomment:
File Added - 88445: typescript
- login: "tmh"
- mimetype: "text/plain"
- username: "tmh"
- icomment:
Add attachment "typescript" [4012c0cb64] (rid 121563) by tmh on 2004-05-26 10:50:29.
Ticket change [0cd64fe5c5] (rid 114246) by tmh on 2004-05-26 11:01:44:
- icomment:
Logged In: YES user_id=92123 I have attached a file showing my gdb session and the results.
- login: "tmh"
- mimetype: "text/plain"
- username: "tmh"
- icomment:
Ticket change [4344bf642a] (rid 116527) by tmh on 2004-05-30 21:42:19:
- icomment:
Logged In: YES user_id=92123 I have found some additional information from oracle.. --------------- symptom: Dynamically unloading shared library fails symptom: SIGSEGV 11* segmentation violation symptom: Core dump is generated cause: A program, either Pro*C or OCI, that dynamically loads and unloads a shared library that includes libclntsh.so will cause a core dump on exit after dynamically unloading the shared library. This will only occur if a connect and disconnect to Oracle is performed. This documented in <bug:2012268>:CORE DUMP ON EXIT OF PRO*C PROGRAM USING DLCLOSE(). The dlopen loads the users shared object, and this in turn causes libclntsh.so to be loaded into the program. The Oracle trace code in the client registers an exit handler by calling "atexit()". This registers a function which resides inside libclntsh.so to be called at exit from the process. dlclose() unloads the users library and libclntsh.so. exit() tries to call "epc_exit_handler" which is now unmapped. ------- Since Tcl 8.5 now calls dlclose for packages where 8.4 apparently does not. Would it be too late for a feature that allows package writers the option to skip the dlclose ? Also, Oracle provides a solution (hack) to get around the core dump. This is apparently a Solaris only issue. Workaround (Solaris specific): Before starting the process which performs dlopen/dlclose of a module linked with Oracle set the environment variable LD_PRELOAD to point to the libclntsh.so file that is being used. For example: setenv LD_PRELOAD $ORACLE_HOME/rdbms/lib/libclntsh.so.8.0 This maps libclntsh permanently and avoids the core dump. This variable must only be set for programs that encounter the core dump and not set generally. Since this is clearly Oracle's fault, Would someone kindly change the close the status of this bug report. Thanks Todd
- login: "tmh"
- mimetype: "text/plain"
- username: "tmh"
- icomment:
Ticket change [5209d0c0e6] (rid 126240) by tmh on 2004-05-30 22:56:02:
- icomment:
File Added - 88949: diff Logged In: YES user_id=92123 I have found a solution but the impact on others, I cannot address... It would be nice if there was an API to turn on/off thischange for particular packages . Something like package require -preserve Oratcl
- login: "tmh"
- mimetype: "text/plain"
- username: "tmh"
- icomment:
Add attachment "diff" [52c9cb8616] (rid 126376) by tmh on 2004-05-30 22:56:02.
Ticket change [b2f3634bb4] (rid 98429) by dgp on 2004-06-01 00:30:18:
- icomment:
Logged In: YES user_id=80530 [package require] is the wrong place to add tweaks to the operation of [load] and [unload].
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [2fea43777f] (rid 93153) by tmh on 2004-06-01 00:38:44:
- icomment:
Logged In: YES user_id=92123 Ok I agree that package require is the wrong place to tweak. I am wondering if this is not related to TIP 100. I do not have a Oratcl_Unload proc defined, so I do not know why the oratcl library is being unloaded. Do you have any comments on the patch to tclLoadDl.c that I have uploaded. I really would like to figure this out before Tcl 8.5 is released stable as this will be a nightmare to support. Thanks Todd
- login: "tmh"
- mimetype: "text/plain"
- username: "tmh"
- icomment:
Ticket change [31faab86f0] (rid 93528) by tmh on 2005-02-17 02:04:14:
- icomment:
Logged In: YES user_id=92123 New version of Oratcl does not suffer from this behavior so I am canceling the bug report.
- login: "tmh"
- mimetype: "text/plain"
- resolution changed to: "Wont Fix"
- username: "tmh"
- icomment:
Ticket change [a65582a1ea] (rid 98585) by hobbs on 2005-02-17 08:52:25:
- icomment:
Logged In: YES user_id=72656 dup as 1011715
- login: "hobbs"
- mimetype: "text/plain"
- resolution changed to: "Duplicate"
- status changed to: "Closed"
- username: "hobbs"
- icomment:
Ticket change [64b6ab23b9] (rid 92816) by hobbs on 2005-02-17 08:52:26:
- closedate changed to: "2005-02-17T01:52:26"
- closer changed to: "hobbs"