Barrier sync blocks thread when queue isn't running
| Originator: | michele.titolo | ||
| Number: | rdar://17696610 | Date Originated: | 7/16/2014 |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | 7.1.2 (11D257) |
| Classification: | Crash/Hang/Data Loss | Reproducible: | Sometimes |
Summary:
Occasionally a dispatch_barrier_sync will block the main thread. It will do this even when the queue passed into the function call isn't running. It also happens when the queue is running, but not suspended, and while the queue is suspended.
It gets into this state:
<OS_dispatch_queue: com.hackemist.SDWebImageDownloaderBarrierQueue[0x15dfa800] = { xrefcnt = 0x1, refcnt = 0x2, suspend_cnt = 0x0, locked = 1, target = com.apple.root.default-priority[0x3b43a580], width = 0x7fffffff, running = 0x0, barrier = 0 }>
Steps to Reproduce:
**NOTE: Due to a bug in Xcode 6 (rdar://17696438), this can only be reproduced using Xcode 5**
Code: https://github.com/mtitolo/cats/tree/sdwebimage-scrolling
How to reproduce:
1. Set a breakpoint in applicationDidFinishLaunching...
2. Get a device, iPhone 4 or equiv, and enable Network Link Conditioner on the 3G setting.
2. Run on the device.
3. When the breakpoint is hit, in lldb run breakpoint set -n semaphore_wait_trap
4. Next, run script and paste in this:
find_in_stack = ['-[SDWebImageDownloader addProgressCallback:andCompletedBlock:forURL:createCallback:]']
def continue_ignored(frame, bp_loc, dict):
global find_in_stack
names = set([frame.GetFunctionName() for frame in frame.GetThread()])
all_ignored = set(find_in_stack)
ignored_here = all_ignored.intersection(names)
if len(ignored_here) == 0:
frame.GetThread().GetProcess().Continue()
quit()
There are a number of semaphore_wait_traps that we want to skip. We are only interested in ones with -addProgressCallback:... in its stack frame
5. Lastly, run br comm add -F continue_ignored 2 where 2 is the ID of the breakpoint printed from step 1 (it may be a different number).
6. Continue. Scroll around a bit, and the breakpoint will be hit.
Expected Results:
A queue that is not running should not block the thread.
Actual Results:
It blocks the thread, sometimes for 4-6 seconds.
Version:
7.1.2 (11D257)
Notes:
Configuration:
iPhone 4 64GB GSM
Attachments:
'stackshots.zip' was successfully uploaded.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!