[Starkit] TclKit segfault when using an extension
Trevor Davel
TrevorD at prism.co.za
Tue May 23 13:57:20 CEST 2006
Hi,
I am using TclKit 8.4.13 on Linux (Fedora Core 4) in conjunction with an
in-house extension (which is stubs enabled). I have already struggled
through problems with the static TclKit, and am now using the dynamic one
... but still having issues with segfaults. Any advice would be
appreciated.
Thanks,
Twylite
System information:
---
[trevord at dbn-fc4-td lib]$ uname -a
Linux dbn-fc4-td 2.6.11-1.1369_FC4 #1 Thu Jun 2 22:55:56 EDT 2005 i686 i686
i386 GNU/Linux
---
The extension is DcmLinDrv (a library to access one of our hardware
devices). It is a port of a Windows DLL.
---
[trevord at dbn-fc4-td lib]$ ldd libDcmLinDrv.so
linux-gate.so.1 => (0x006d2000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00444000)
libuuid.so.1 => /lib/libuuid.so.1 (0x003c7000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00111000)
libm.so.6 => /lib/libm.so.6 (0x007f7000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00af1000)
libc.so.6 => /lib/libc.so.6 (0x001fa000)
/lib/ld-linux.so.2 (0x003f1000)
---
I can successfully load and use this DLL under the tcl interpreter that
comes with Fedora Core 4.
---
[trevord at dbn-fc4-td lib]$ ldd /usr/bin/tcl
linux-gate.so.1 => (0x00cb9000)
libtclx8.3.so => /usr/lib/libtclx8.3.so (0x006fd000)
libtcl8.4.so => /usr/lib/libtcl8.4.so (0x00652000)
libdl.so.2 => /lib/libdl.so.2 (0x00561000)
libm.so.6 => /lib/libm.so.6 (0x0053b000)
libc.so.6 => /lib/libc.so.6 (0x0040f000)
/lib/ld-linux.so.2 (0x003f1000)
---
But when I try to run under tclkit (dynamic), I get a segfault -- not
immediately on loading, but in C++ library code.
---
trevord at dbn-fc4-td lib]$ ldd ./tclkit-linux-x86-8.4.13
linux-gate.so.1 => (0x00bb7000)
libdl.so.2 => /lib/libdl.so.2 (0x00561000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00785000)
libm.so.6 => /lib/libm.so.6 (0x0053b000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00779000)
libc.so.6 => /lib/libc.so.6 (0x0040f000)
/lib/ld-linux.so.2 (0x003f1000)
---
Significant differences between tcl and tclkit:
- TclKit links against libstdc++.so.6 and libgcc_s.so.1 ; so does our
extension
- The extension uses pthreads -- I don't know if tcl and/or tclkit are
compiled with _REENTRANT, and whether this could make a difference.
Here's what gdb tells me:
---
[trevord at dbn-fc4-td lib]$ gdb ./tclkit-linux-x86-8.4.13
GNU gdb Red Hat Linux (6.3.0.0-1.21rh)
(...snip gdb version header...)
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) set args ../test/test_itsm_complete.tcl
(gdb) run
Starting program:
/home/trevord/tmp/PrismLDD_0.2beta-td/DcmLinDrv/lib/tclkit-linux-x86-8.4.13
../test/test_itsm_complete.tcl
Reading symbols from shared object read from target memory...(no debugging
symbols found)...done.
Loaded system supplied DSO at 0x689000
(no debugging symbols found)
(...snip more warnings about debugging symbols...)
----- Initialisation
Loading ITSM extension library ...
[Thread debugging using libthread_db enabled]
[New Thread -1208715584 (LWP 15238)]
+OK Library loaded
(...snip test program output...)
(...several calls to the extension pass successfully ! ...)
Testing open with mode argument ...
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208715584 (LWP 15238)]
0x001e0b3f in __gnu_cxx::__pool<true>::_M_adjust_freelist (this=0x1eb360,
__bin=@0x8d0c5c8, __block=0x8cf7378, __thread_id=0)
at
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c++/4.0.0/ext/mt_al
locator.h:356
356 --__bin._M_free[__thread_id];
Current language: auto; currently c++
(gdb) bt
#0 0x001e0b3f in __gnu_cxx::__pool<true>::_M_adjust_freelist
(this=0x1eb360,
__bin=@0x8d0c5c8, __block=0x8cf7378, __thread_id=0)
at
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c++/4.0.0/ext/mt_al
locator.h:356
#1 0x001e1a87 in
__gnu_cxx::__mt_alloc<std::_Rb_tree_node<std::pair<std::string const, int>
>,
__gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, true> >::allocate
(this=0x8d1a2a8, __n=1)
at
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c++/4.0.0/ext/mt_al
locator.h:721
#2 0x001e1ade in std::_Rb_tree<std::string, std::pair<std::string const,
int>, std::_Select1st<std::pair<std::string const, int> >,
std::less<std::string>, std::allocator<std::pair<std::string const, int> >
>::_M_get_node (this=0x8d1a2a8)
at
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c++/4.0.0/bits/stl_
tree.h:356
#3 0x001e1af6 in std::_Rb_tree<std::string, std::pair<std::string const,
int>, std::_Select1st<std::pair<std::string const, int> >,
std::less<std::string>, std::allocator<std::pair<std::string const, int> >
>::_M_create_node (
this=0x8d1a2a8, __x=@0xbfc5eec8)
at
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c++/4.0.0/bits/stl_
tree.h:365
#4 0x001e1c15 in std::_Rb_tree<std::string, std::pair<std::string const,
int>, std::_Select1st<std::pair<std::string const, int> >,
std::less<std::string>, std::allocator<std::pair<std::string const, int> >
>::_M_insert (this=0x8d1a2a8,
---Type <return> to continue, or q <return> to quit---
__x=0x0, __p=0x8d1a2ac, __v=@0xbfc5eec8)
at
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c++/4.0.0/bits/stl_
tree.h:793
#5 0x001e1d6c in std::_Rb_tree<std::string, std::pair<std::string const,
int>, std::_Select1st<std::pair<std::string const, int> >,
std::less<std::string>, std::allocator<std::pair<std::string const, int> >
>::insert_unique (
this=0x8d1a2a8, __v=@0xbfc5eec8)
at
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c++/4.0.0/bits/stl_
tree.h:882
#6 0x001e1f34 in std::_Rb_tree<std::string, std::pair<std::string const,
int>, std::_Select1st<std::pair<std::string const, int> >,
std::less<std::string>, std::allocator<std::pair<std::string const, int> >
>::insert_unique (
this=0x8d1a2a8, __position={_M_node = 0x8d1a2ac}, __v=@0xbfc5eec8)
at
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c++/4.0.0/bits/stl_
tree.h:904
#7 0x001e20a2 in std::map<std::string, int, std::less<std::string>,
std::allocator<std::pair<std::string const, int> > >::insert
(this=0x8d1a2a8,
position=
{_M_node = 0x8d1a2ac}, __x=@0xbfc5eec8)
at
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c++/4.0.0/bits/stl_
map.h:384
#8 0x001e2181 in std::map<std::string, int, std::less<std::string>,
std::allocator<std::pair<std::string const, int> > >::operator[]
(this=0x8d1a2a8,
__k=@0xbfc5eefc)
---Type <return> to continue, or q <return> to quit---
at
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c++/4.0.0/bits/stl_
map.h:339
#9 0x001e0962 in HotPlugInformationManager::registerDevice (this=0x8d1a2a8,
szPciId=0xbfc5ef28 "01:0d.0", devNum=0)
at HotPlugInformationManager_Lin.cpp:16
#10 0x001e03ca in Tsm410Device::_win_openDevice (this=0x8d1ec60, async=true)
at DevTsm410_Lin.cpp:103
#11 0x001e03e5 in Tsm410Device::_openDevice (this=0x8d1ec60)
at DevTsm410_Lin.cpp:302
#12 0x001def0d in CDevTsm410Base::init (this=0x8d1ec60,
mode=InitType_START_FIRMWARE) at DevTsm410Base.cpp:111
#13 0x001dfb20 in Tsm410Device::init (this=0x8d1ec60,
mode=InitType_START_FIRMWARE) at DevTsm410_Lin.cpp:162
#14 0x001dd9eb in DcmDeviceInit (bDevice=10 '\n', bMode=0 '\0')
at DcmNtDrv.cpp:423
#15 0x001e3959 in tcl_itsm_open (cd=0x0, interp=0x8ce7170, argc=3,
argv=0xbfc5f1b0) at itsm_tcl.cpp:410
#16 0x08068191 in TclEvalObjvInternal ()
#17 0x08069a04 in Tcl_EvalEx ()
#18 0x0806a280 in Tcl_EvalTokensStandard ()
#19 0x08069989 in Tcl_EvalEx ()
#20 0x080af134 in Tcl_FSEvalFile ()
#21 0x080b2c50 in Tcl_Main ()
---Type <return> to continue, or q <return> to quit---
#22 0x080659c7 in main ()
---
I have tried using Tclkit-lite, but it also generates a segfault (at a
different location, but while accessing a C++ member variable ; some
extension functions which use C++ do run successfully before that point).
I have also tried compiling Tclkit myself using the genkit script and the
"Building TclKit" instructions at http://www.equi4.com/218 . In this case
both tclkit and libDcmLinDrv.so (the extension) are compiled on the same box
using the same compiler. I get the same results as the downloaded dynamic
TclKit.
---
[trevord at dbn-fc4-td lib]$ gcc -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
--host=i386-redhat-linux
Thread model: posix
gcc version 4.0.0 20050519 (Red Hat 4.0.0-8)
---
The possibilities I haven't managed to look into yet are:
- Possible pthreads / -D_REENTRANT conflict when both the tcl interpreter
and extension use libstdc++. Is there any way I can compile TclKit with
threads enabled?
- TclKit seems to use .a libraries of zlib, tclvfs and mk when it links --
could these have statically linked pthreads/C++ code that is causing a
conflict?
More information about the Starkit
mailing list