#2803 NotifierThreadProc missing TclpThreadExit at end

closed-fixed
7
2004-07-16
2004-07-13
Joe Mistachkin
No

I believe the NotifierThreadProc function in
"unix/tclUnixNotfy.c" should end with a call to
TclpThreadExit, to allow the pthread library to clean
up any internal resources associated with the notifier
thread.

The general principal here is that threads created with
TclpThreadCreate must be exited using TclpThreadExit.

Discussion

    • priority: 5 --> 7
     
  • Logged In: YES
    user_id=75003

    Hm. The description of that function says:

    Once started, this routine never exits. It dies with the
    overall process.

    In other words, even if we add TclpThreadExit it will never
    be reached, right ?

    Hm, looking at the code instead I find that there is a way
    for the thread proc to exit, via a 'break' in its infinite
    loop. And that is done in response to reception of a 'quit
    message'. There is some other cleanup happening already ...
    I guess we can do the TclpThreadExit as well, as the very
    last action.

    Still, given Zoran's recent experience in this area (threads
    & notifier) I wait a bit on this will ask some other people
    to have a look at this as well.

     
  • Logged In: YES
    user_id=95086

    I believe Joe is right. Every thread created by pthread_create
    should eventually call pthread_exit at the end of its life.
    Otherwise pthread library leaks.
    At this particular spot this is not very tragic for tclsh-like
    applications where main thread and the notifier thread
    exit just at the end of the app. But in systems loading
    and finalizing Tcl library as a subsystem, this may pose
    memory problems (leaks).

    My oppinion is: go ahead and add the TclpThreadExit
    at the end.

     
  • Logged In: YES
    user_id=75003

    Accepted and committed the change, to both head and 8.4 branch

     
    • status: open --> closed-fixed