Why does this code cause “EXC_BAD_INSTRUCTION”?
问题 dispatch_semaphore_t aSemaphore = dispatch_semaphore_create(1); dispatch_semaphore_wait(aSemaphore, DISPATCH_TIME_FOREVER); dispatch_release(aSemaphore); When the program runs to dispatch_release(aSemaphore) , it will cause "EXC_BAD_INSTRUCTION", and then crash. Why? 回答1: I tried this code and it does indeed die with illegal instruction. So I did some digging and found that it's dying in _dispatch_semaphore_dispose. So let's look at what that is (ARMv7 here, because it's easy to understand!):