Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: ddebb9b784d0cdf022058b1e28172ec9c03748c5
Ticket: 2869384fffffffffffffffffffffffffffffffff
Tcl_AsyncMark does not work with --enable-threads
User & Date: eugene_cdn on 2010-03-02 10:20:51
Changes

  1. icomment:
    Sorry for long absence.
    1) As I mentioned before, recursive mutex does not protect "protected data" from corruption in signal handler.
    2) I made Tcl testcase much more reliable, it hangs just in seconds. Need to change timeout in C code to 100 us and in Tcl to 1 ms and decrease printing. Attaching run3.tcl to use with tclsh.
    3) After making mutexes recursive and using modified testcase, it hangs in the same place. I collected a number of different stacks. Last one:
       Tcl_WaitForEvent(timePtr = 0x22328)
       Tcl_MutexUnlock(mutexPtr = 0xff38294c)
       __mutex_unlock(0x2b468, 0x1000, 0xfef6cbc0, 0xff072000, 0x2b470, 0x6)
       --- Signal SIGALRM raised ---
       __sighndlr(0xe, 0x0, 0xffbfe4f0, 0xfee20678, 0x0, 0x1)
       GotAlarm(signo = 14)
       Tcl_AsyncMark(async = 0x51738)
       Tcl_ThreadAlert(threadId = 0x1)
       Tcl_AlertNotifier(clientData = 0x2bbe8)
       Tcl_MutexLock(mutexPtr = 0xff38294c)
       mutex_lock_queue(0x0, 0x0, 0x2b468, 0x0, 0x0, 0x1)
       __lwp_park(0x0, 0x0, 0x0, 0x0, 0xfee50000, 0x1)
    4) You search web for "pthread_mutex_lock async signal safety" and you will
       find that you cannot use mutexes in signal handler at all! Here's an example
       of finding:
    ASYNC-SIGNAL SAFETY
                    The mutex functions are not async-signal safe. What this means is  that
            they should not be called from a signal handler. In particular, calling
            pthread_mutex_lock or pthread_mutex_unlock from a signal handler may
            deadlock the calling thread.
    This all means that direction of the research is wrong. Tcl_AsyncMark must be mutex free or must not be used in signal handler.
    
    
    
  2. login: "eugene_cdn"
  3. mimetype: "text/plain"
  4. username: "eugene_cdn"