Email List: Xaustin-review-lX
[All Lists]

Defect in XSH pthread_cancel -- cancel execution of a thread

To: yyyyyyyyyyyyyyy@xxxxxxxxxxxxx
Subject: Defect in XSH pthread_cancel -- cancel execution of a thread
From: yyyyyyyy@xxxxxxxxxx
Date: Fri, 4 Apr 2003 15:53:45 +0100 (BST)
        Defect report from : Alexander Terekhov , IBM

(Please direct followup comments direct to yyyyyyyyyyyyyy@xxxxxxxxxxxxx)

@ page 1018 line 31994 section pthread_cancel -- cancel execution of a thread 
comment {alt-pthread_cancel-2003-04-04}

Problem:

Defect code :  2. Omission

Please consider the following piece of code:

     ....
     int state;
     pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state);
     if (PTHREAD_CANCEL_ENABLE == state) {
       pthread_setcancelstate(state, &state);
       pthread_cancel(pthread_self());
       pthread_testcancel();
     }
     ....

-and-

     ....
     int state;
     pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state);
     if (PTHREAD_CANCEL_ENABLE == state) {
       pthread_setcancelstate(state, &state); // Uh...
       //pthread_cancel(pthread_self());
       //pthread_testcancel();
       pthread_exit(PTHREAD_CANCELED);
     }
     ....

I just want that the code along these lines would NOT cause any 
problems when executed in the scope of some cleanup handler or 
some TSD-destructor. I'm afraid that with the current wording,
executing such code in the scope of some cleanup handler or 
some TSD-destructor MAY cause problems. I want more clarity with
respect to the VALUES of cancelability TYPE and STATE set by the 
implementation prior to "cleanup-unwinding" and TSD-destruction.


Action:

Insert the following wording (or something like that) at 31994:

<insert>

Before cancellation cleanup handlers followed by thread-specific 
data destructor functions are executed, the thread's cancelability 
state shall be set to PTHREAD_CANCEL_DISABLE and thread's 
cancelability type shall be set to PTHREAD_CANCEL_DEFERRED.

</insert>

<Prev in Thread] Current Thread [Next in Thread>
  • Defect in XSH pthread_cancel -- cancel execution of a thread, terekhov <=