Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Unix Tcl_Exit behavior incorrect with TCL_THREADS

Closed / Remind990457ffffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 17 years ago
Descriptionplain2004-07-13 20:52:21
in "generic/tclEvent.c" near line 644, the code reads:

/* use default handling */
Tcl_Finalize();
TclpExit(status);
Tcl_Panic("OS exit failed!");

the above code should read:

/* use default handling */
Tcl_Finalize();
#ifdef TCL_THREADS
TclpThreadExit(status);
#else
TclpExit(status);
#endif
Tcl_Panic("OS exit failed!");

This fixes an annoying memory leak when TCL_THREADS is
enabled.  I believe this change should be backported to
core-8-4-branch.
dgp Ticket [990457ffff]: 1 change [History diff]2004-07-15 03:14:34
dgp Ticket [990457ffff]: 2 changes [History diff]2004-07-15 03:14:35
hobbsplain2004-11-18 01:05:51
Logged In: YES 
user_id=72656

This suggestion causes all sorts of crashes in 'make test'.
mistachkinplain2004-12-01 00:19:22
Logged In: YES 
user_id=113501

My proposed fix may cause the test suite to crash, however,
the current code is wrong and can cause quite a few
memory/resource leaks.
mistachkinplain2005-03-03 14:52:30
Logged In: YES 
user_id=113501


Jeff, what platform is "make test" producing failures on and
what are the failures?  I'm trying to pin down the real root
cause.
hobbsplain2005-03-04 04:04:06
Logged In: YES 
user_id=72656

On Linux, apply patch and build the head with
--enable-threads.  Do make test.  Watch it bomb all over the
place:

Tests began at Thu Mar 03 13:03:11 -0800 2005
append.test
Test file error: child killed: segmentation violation
appendComp.test
Test file error: child killed: segmentation violation
assocd.test
Test file error: child killed: segmentation violation
async.test
Test file error: child killed: segmentation violation
....
hobbs Pending ticket [990457ffff]. [History diff]2005-05-31 09:17:13
mistachkinplain2005-05-31 12:26:26
Logged In: YES 
user_id=113501


It's crashing on exit.  This is still a valid bug because if
you create a thread using Tcl_CreateThread and invoke [exit]
(or Tcl_Exit), pthread_exit (or the equiv on Win32) is never
called.  This is technically a leak.  A slightly more
complex solution to this is required and I will start
working on it soon.
dgpplain2006-03-10 12:57:44
Logged In: YES 
user_id=80530


Tcl's finalization has been revised.

Joe's patch no longer causes
crashes on exit running the test suite
on HEAD.

However, now that the crashes are
gone, several failing tests are
revealed (see below).  Looks like
the proposed patch changes the
behavior of [exit] in an [exec]-ed
process in an incompatible way.

Failing tests are:

event-10.1
exec-9.{3,4}
Tcl_Main-3.{1-4}
tcltest-1.{1,2}
tcltest-22.1
mistachkinplain2008-10-03 02:31:02
Also see 2001201.
ferrieuxplain2009-06-18 03:05:21
Now 2001201 has been applied, please retest.
dkfplain2009-06-18 15:20:20
Believed fixed (i.e. other probably-related bugs are fixed) so moved to Pending...
sf-robotplain2009-07-03 09:20:21
allow_comments - 1

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).
ferrieuxplain2009-07-15 04:28:53
allow_comments - 0

Joe, your comment ? Does the current state satisfy you ?
mistachkinplain2009-07-15 04:43:07
I'm not sure if the change technically "fixes" this bug; however, I am happy with the changes.
ferrieuxplain2009-07-16 05:40:25
Indeed, after a second look it doesn't. Rather, it takes further apart the concepts of (quick) exit and (thorough) finalization. Which defeats methods based on an atexit() handler to look for memory leaks. But since the problem of cleanly shutting down other threads is unsolvable, I guess the limitation must be lived with.
Log in (anonymous is fine) to add a comment.