I'm not sure if this is the right list for this, but then I'm not sure what is 
the right list.

I'm seeing a consistent problem disposing of GCD semaphores. For example, if I 
create a semaphore like this:

        semaphore = dispatch_semaphore_create (10);

and then use if for a while, then try to destroy it (using ARC):

        semaphore = nil;

If the semaphore's count is less than the original value (10 in the example), I 
get a EXC_BAD_INSTRUCTION crash:

> #0  0x00007fff91fcfb5f in _dispatch_semaphore_dispose ()
> #1  0x00007fff91fcc898 in _dispatch_dispose ()
> #2  0x00007fff91fcc837 in -[OS_dispatch_object _xref_dispose] ()

> 0x00007fff91fcfb3e  <+0000>  push   %rbp
> 0x00007fff91fcfb3f  <+0001>  mov    %rsp,%rbp
> 0x00007fff91fcfb42  <+0004>  push   %rbx
> 0x00007fff91fcfb43  <+0005>  push   %rax
> 0x00007fff91fcfb44  <+0006>  mov    %rdi,%rbx
> 0x00007fff91fcfb47  <+0009>  mov    0x38(%rbx),%rax
> 0x00007fff91fcfb4b  <+0013>  cmp    0x40(%rbx),%rax
> 0x00007fff91fcfb4f  <+0017>  jge    0x7fff91fcfb61 
> <_dispatch_semaphore_dispose+35>
> 0x00007fff91fcfb51  <+0019>  lea    0xa8a6(%rip),%rcx        # 0x7fff91fda3fe
> 0x00007fff91fcfb58  <+0026>  mov    %rcx,-0x17cbe317(%rip)        # 
> 0x7fff7a311848 <gCRAnnotations+8>
> 0x00007fff91fcfb5f  <+0033>  ud2a   << Thread 1: Program received signal: 
> 'EXC_BAD_INSTRUCTION'

It's not clear to me why it should matter whether the original count has been 
restored. There's nothing waiting on the semaphore -- the operations that 
decremented the count have themselves be disposed of already.

If I forcibly increment the count to 10 *or more*, there's no crash.



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to