Yes, unfortunately it does not seem to matter. The bug is present also with c99 
-D_XOPEN_SOURCE=600

spdev@SPs-Mac ~ % uname -a && rm -f ./a.out && c99 -D_XOPEN_SOURCE=600 
cancel_leak.c && while true; do time ./a.out 100000000 10; done
Darwin SPs-Mac.local 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 
PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64 x86_64
Starting test, 100000000 iterations, sleep interval 10ms
cancel_leak.c:46: ERROR cancelled while PTHREAD_CANCEL_DISABLE
zsh: illegal hardware instruction  ./a.out 100000000 10
./a.out 100000000 10  21.47s user 112.79s system 1% cpu 2:32:32.73 total
Starting test, 100000000 iterations, sleep interval 10ms
cancel_leak.c:46: ERROR cancelled while PTHREAD_CANCEL_DISABLE
zsh: illegal hardware instruction  ./a.out 100000000 10
./a.out 100000000 10  6.85s user 34.88s system 1% cpu 1:08:58.65 total
Starting test, 100000000 iterations, sleep interval 10ms
cancel_leak.c:46: ERROR cancelled while PTHREAD_CANCEL_DISABLE
zsh: illegal hardware instruction  ./a.out 100000000 10
./a.out 100000000 10  10.77s user 56.04s system 1% cpu 1:11:28.98 total
Starting test, 100000000 iterations, sleep interval 10ms
cancel_leak.c:46: ERROR cancelled while PTHREAD_CANCEL_DISABLE
zsh: illegal hardware instruction  ./a.out 100000000 10
./a.out 100000000 10  1.42s user 7.13s system 1% cpu 9:10.69 total
...


> On 21 Oct 2019, at 13:21, Geoff Clare <g...@opengroup.org> wrote:
> 
> Per Mildner <per.mild...@ri.se> wrote, on 21 Oct 2019:
>> 
>> As far as I know, no version of macOS, including macOS version 10.15 
>> Catalina, has implemented thread cancellation correctly (the first few 
>> certified version did not implement it at all, the more recent ones 
>> implement it incorrectly).
>> 
>> https://openradar.appspot.com/9137682 
>> <https://openradar.appspot.com/9137682>, first reported to Apple in 2011, 
>> shows that PTHREAD_CANCEL_DISABLE does not prevent pthread_cancel from 
>> cancelling a thread. This is still true in Catalina. This makes thread 
>> cancellation unreliable, and there is no workaround that I know of.
>> 
>> I do not think that a working PTHREAD_CANCEL_DISABLE is optional in UNIX 03, 
>> but I may be mistaken.
> 
> The report at openradar shows compilations with cc and gcc.  To ensure
> conforming behaviour you need to compile with c99 -D_XOPEN_SOURCE=600
> (where c99 is the macOS front-end to clang).
> 
> Do you get the same result if you compile that way?
> 
> -- 
> Geoff Clare <g.cl...@opengroup.org>
> The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England
> 

Per Mildner
RISE ICT/SICS



Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to