You are here:

C++/pesky core dump. pls help - string class??

Advertisement


Question
Hi, Thanks for the quick reply. I have gone through the code thoroughly but cannot seem to locate a place where any "global" variable is being freed. We use strictly "local" variables within the threads.

Something I came across the net was that using the stl "string" class can have issues in multi-threading environment. Is that true? Also this code has been running on AIX without any crashes. But Solaris doesn't seem to be that forgiving...

- Bimal

-------------------------
Followup To
Question -
Hi,

I have a multi-threaded g++ program on Solaris which is crashing on different sections on different occasions. The core inspection tells me that it goes through calls like...

realfree ()
_malloc_unlocked ()
malloc ()

I checked various forums and some pople seem to think it is a issue with using "string" class in multi-threaded environment with dynamic linking. Can you comment on this?

System is...

Sunfire v440 sparc
Solaris 9
gcc/g++ 3.3
Oracle 10G

And the full backtrace is...

...
...
Bus Error - core dumped
iswitch% gdb TrxEngine core
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.8"...(no debugging
symbols found)...
Core was generated by 'TrxEngine'.
Program terminated with signal 9, Killed.
Reading symbols from /usr/lib/libnsl.so.1...(no debugging symbols found)...done.
Reading symbols from /usr/lib/libdl.so.1...(no debugging symbols found)...done.
Reading symbols from /export/home/oracle/lib32/libclntsh.so.10.1...(no
debugging symbols found)...done.
Reading symbols from /usr/lib/libresolv.so.2...(no debugging symbols
found)...done.
Reading symbols from /usr/lib/libsocket.so.1...(no debugging symbols
found)...done.
Reading symbols from /usr/lib/libpthread.so.1...(no debugging symbols
found)...done.
Reading symbols from /usr/local/lib/libstdc++.so.5...done.
Reading symbols from /usr/lib/libm.so.1...done.
Reading symbols from /usr/local/lib/libgcc_s.so.1...done.
Reading symbols from /usr/lib/libc.so.1...done.
Reading symbols from /usr/lib/libmp.so.2...done.
Reading symbols from /export/home/oracle/lib32/libnnz10.so...done.
Reading symbols from /usr/lib/libkstat.so.1...done.
Reading symbols from /usr/lib/libgen.so.1...done.
Reading symbols from /usr/lib/libsched.so.1...done.
Reading symbols from /usr/lib/libaio.so.1...done.
Reading symbols from /usr/lib/librt.so.1...done.
Reading symbols from /usr/lib/libmd5.so.1...done.
Reading symbols from /usr/platform/SUNW,Sun-Fire-V440/lib/libc_psr.so.1...done.
Reading symbols from /usr/lib/libthread.so.1...done.
#0  0xfe347abc in t_splay () from /usr/lib/libc.so.1
(gdb) bt
#0  0xfe347abc in t_splay () from /usr/lib/libc.so.1
#1  0xfe34782c in t_delete () from /usr/lib/libc.so.1
#2  0xfe34744c in realfree () from /usr/lib/libc.so.1
#3  0xfe346f90 in _malloc_unlocked () from /usr/lib/libc.so.1
#4  0xfe346d08 in malloc () from /usr/lib/libc.so.1
#5  0xff1e15e4 in _Znwj (sz=140) at
../../../../libstdc++-v3/libsupc++/new_op.cc:48
#6  0xff1d6264 in _ZNSt24__default_alloc_templateILb1ELi0EE8allocateEj (__n=140)
  at /usr2/SOURCES/S8/gcc-3.3/objdir/sparc-sun-solaris2.8/libstdc++-v3/include/bits/stl_alloc.h:108
#7  0x967dc in _ZNSt14__simple_allocISt13_Rb_tree_nodeISt4pairIKSs14GenericMessageEESt24__default_alloc_templateILb1ELi0
EEE8allocateEj ()
#8  0x96734 in _ZNSt19_Rb_tree_alloc_baseISt4pairIKSs14GenericMessageESaIS3_ELb1EE11_M_get_nodeEv
()
#9  0x96600 in _ZNSt8_Rb_treeIKSsSt4pairIS0_14GenericMessageESt10_Select1stIS3_ESt4lessIS0_ESaIS3_EE14_M_create_nodeERKS
3_ ()
#10 0x94fb8 in _ZNSt8_Rb_treeIKSsSt4pairIS0_14GenericMessageESt10_Select1stIS3_ESt4lessIS0_ESaIS3_EE9_M_insertEPSt18_Rb_
tree_node_baseSB_RKS3_ ()
#11 0x948e8 in _ZNSt8_Rb_treeIKSsSt4pairIS0_14GenericMessageESt10_Select1stIS3_ESt4lessIS0_ESaIS3_EE12insert_equalERKS3_
()
#12 0x93f6c in _ZNSt8multimapIKSs14GenericMessageSt4lessIS0_ESaISt4pairIS0_S1_EEE6insertERKS5_
()
#13 0x93ef8 in _ZN15TranslatorLogic17addHistoryMessageESsR14GenericMessage ()
#14 0x44be8 in _ZN22InternalMessageHandler20processSingleMessageESsSsRN12AdvXMLParser7ElementERKS1_
()
#15 0x43b7c in _ZN22InternalMessageHandler14processRequestEv ()
#16 0x3d9a8 in _ZN16FrameworkManager26processInternalTransactionEPv ()
(gdb)

Answer -
That's hard to comment, based on the given information. But I guess your code is trying to delete/free some memory which is already deleted or you try to access it after it is deleted. In multi-thread codes, this happens frequently. For instance, you delete some data in one thread and try to access or delete it again in another thread.
I hope this helps.

Answer
Many things could cause such dump. I suggest you to compile your program with debuging information included and try to trace your program and check when you get the error. This will help you even if there is a bug in Solaris library. However note that some OSs take memory handling errors easy, but solaris most of the time catches such errors.

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Sam

Expertise

You may ask me about simple to complicated C/C++ programming methods/style and most like questions about network programming in C++.

Experience

I'm a professional programer in C++ and network/internet programming.

©2016 About.com. All rights reserved.