Tcl Source Code

View Ticket
Login
Ticket UUID: 1063988
Title: tcl crash on sun using threads
Type: Bug Created on: 2004-11-10 17:59:53
Submitter: yahalom Assigned to: vasiljevic
Subsystem: 49. Threading Severity:
Priority: 8 Last modified: 2004-11-25 23:06:08
Status: Closed Closed by: vasiljevic
Resolution: Wont Fix Closed on: 2004-11-25 16:06:08
Version: obsolete: 8.4.7
Description:
Tcl Version 8. 4.7
Thread version: 2.5.2

OS Platform and Version: sunOS sundev 5.6 
Generic_105181-39 sun4u sparc SUNW,Ultra-80

we are running an application that splits to threads 
and works heavily with oracle database.
this application works fine on linux/win and other 
version of sun.

we get many segmantaion fault. running gdb 
resulted in few cases:
1. 

alloc: invalid block: 94c6e8: 0 68 ef


Program received signal SIGABRT, Aborted.
[Switching to LWP 8]
0xef554ca8 in __sigprocmask () 
from /usr/lib/libthread.so.1
(gdb) where
#0  0xef554ca8 in __sigprocmask () 
from /usr/lib/libthread.so.1
#1  0xef54b9d0 in _resetsig () 
from /usr/lib/libthread.so.1
#2  0xef54b18c in _sigon () 
from /usr/lib/libthread.so.1
#3  0xef54dec8 in _thrp_kill () 
from /usr/lib/libthread.so.1

2.

Program received signal SIGSEGV, Segmentation 
fault.
[Switching to LWP 7]
0xef5c693c in _smalloc () from /usr/lib/libc.so.1
(gdb) where
#0  0xef5c693c in _smalloc () from /usr/lib/libc.so.1
#1  0xef5c6980 in malloc () from /usr/lib/libc.so.1
#2  0xef5bb9c4 in calloc () from /usr/lib/libc.so.1

3.

alloc: invalid block: 96c988: 0 88 ef


Program received signal SIGSEGV, Segmentation 
fault.
[Switching to LWP 8]
0x0002bf5c in MoveObjs (fromPtr=0x38a818, 
toPtr=0x12cc18, nmove=189)
    at ../generic/tclThreadAlloc.c:689
689     ../generic/tclThreadAlloc.c: No such file or 
directory.
        in ../generic/tclThreadAlloc.c
(gdb) where
#0  0x0002bf5c in MoveObjs (fromPtr=0x38a818, 
toPtr=0x12cc18, nmove=189)
    at ../generic/tclThreadAlloc.c:689
#1  0x0002bc50 in TclThreadFreeObj 
(objPtr=0x38a818)
    at ../generic/tclThreadAlloc.c:600
#2  0x0001e0e8 in TclFreeObj (objPtr=0x38a818) 
at ../generic/tclObj.c:699


what can cause all of this? 
is there a path we can go to help in tracing the bug?
User Comments:
vasiljevic added on 2004-11-11 16:52:43:
Logged In: YES 
user_id=95086

Ancient Sol2.6, hm? 
 
If the problem would be reproducible on other versions 
and/or platforms... But since you get it only on Sol 2.6 
I'm little bit clueless... 
 
What I see from the trace is the classic memory corruption 
issue. Some C-level code garbled the Tcl_Obj's which  
are being kept on the thread private list. At the moment 
the thread exits, its privately allocated Tcl_Obj's are moved 
to the thread-wide repository in order to reuse them again. 
Now, when following the private linked list there is a problem 
(memory reference) and this cores the process. Too bad. 
 
I know you will not like me for this, but... I would keep the 
threads parked and never let them exit. This way a very 
complex and eventually error-prone garbage collection 
of resources is avoided. Obviously, you would have to 
design some sort of thread-caching-and-reusing. You  
might want to look at the threadpool implementation for 
some ideas. 
 
OTOH, is the update to Sol 2.8 an option?

yahalom added on 2004-11-11 18:18:51:
Logged In: YES 
user_id=130120

are all the crashes from the same cause?
will it help if I trace down at what tcl command it 
happens?
is there something on the tcl level we can do? maybe 
thread locking at certain points?
the upgrading of the solaris is not in our hands. it is a 
customer computer. we can only say that we are sorry 
but our product doesn't work on sol2.6 :-(

vasiljevic added on 2004-11-11 18:38:00:
Logged In: YES 
user_id=95086

Well after looking at others, it seems to me that there 
is a gross memory corruption underway. It is not always 
possible to pinpoint this on a specific Tcl command since 
the problem may be just deferred and happen ages after 
the actual cause. I think, out of the experience, that some 
extension is wrongly handling Tcl objects or otherwise  
corrupting the memory. The fact that this exposed itself 
on Sol2.6 might just be a pure coincidence.  
 
There is not much you can do about that. You might want 
to use Purify (costs money but it's worth it) and try to get 
a better picture about what's really happening under the 
hood. If this is possible, I might give you some tips how to 
do this right, otherwise you wont be happy. 
If not, you might try some open-source stuff (valgrind) 
if they are available on solaris (dunno). We use Purify  
for such things. 
 
Speaking about 2.5.2 and Tcl 8.4.7 they are pretty stable 
in this respect. So the problem might just be in some  
Tcl extensions you're using, which is not MT-safe or simply 
buggy in memory handling. 
 
I do not want to discourage you, but you should prepare 
for a long journey...

vasiljevic added on 2004-11-25 23:06:08:
Logged In: YES 
user_id=95086

Closing this as "Wont Fix" since this is most probably the 
issue with some other C-level extension garbling our memory.