Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8752175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:11:03+00:00 2026-06-13T13:11:03+00:00

I am developing a MacOS X application which runs a large number of background

  • 0

I am developing a MacOS X application which runs a large number of background jobs, using GCD. The background jobs use CLucene to index documents, and access Core Data on a child context.

These jobs are all spawned in short order (using dispatch_async on a queue created with DISPATCH_QUEUE_CONCURRENT), but only 4 do actual work at once. This is accomplished using a dispatch_semaphore_t, by waiting on it when a job begins and releasing it when the job completes.

I’m seeing a very strange, reliably reproducible deadlock when:

  1. Background jobs are still running
  2. The user switches focus to another application, and then back

NSWindow is apparently deadlocking trying to send a notification while displaying the menu bar. This is the stack trace of the main thread when this happens:


#0  0x00007fff870ae6c2 in semaphore_wait_trap ()
#1  0x00007fff8b1bf486 in _dispatch_semaphore_wait_slow ()
#2  0x00007fff8b69c12b in -[_NSDNXPCConnection sendMessage:waitForAck:] ()
#3  0x00007fff8b57ced5 in _CFXNotificationPost ()
#4  0x00007fff8b58bbf3 in CFNotificationCenterPostNotification ()
#5  0x00007fff902ae174 in HIS_XPC_CFNotificationCenterPostNotification ()
#6  0x00007fff8bd3612a in BroadcastToolboxMessage ()
#7  0x00007fff8bd6d063 in MenuBarInstance::Show(MenuBarAnimationStyle, unsigned char, unsigned char, unsigned char) ()
#8  0x00007fff8bd98144 in SetMenuBarObscured ()
#9  0x00007fff8bd97e0f in HIApplication::HandleActivated(OpaqueEventRef*, unsigned char, OpaqueWindowPtr*) ()
#10 0x00007fff8bd95407 in HIApplication::EventObserver(unsigned int, OpaqueEventRef*, void*) ()
#11 0x00007fff8bd636e0 in _NotifyEventLoopObservers ()
#12 0x00007fff898dc018 in -[NSWindow sendEvent:] ()
#13 0x00007fff898d8744 in -[NSApplication sendEvent:] ()
#14 0x00007fff897ee2fa in -[NSApplication run] ()
#15 0x00007fff89792cb6 in NSApplicationMain ()
#16 0x0000000100001e52 in main at /Users/mspong/dev/Indx/Indx/Indx/main.m:13
#17 0x00007fff86b7b7e1 in start ()

All running background jobs finish their work, but no further jobs get access to the aforementioned semaphore. Every thread is stuck on semaphore_wait_trap.

I can’t imagine what I could possibly be doing to (apparently) cause unrelated semaphores (both mine and Apple’s) to get stuck. Can anybody offer some advice on how to investigate this further?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:11:04+00:00Added an answer on June 13, 2026 at 1:11 pm

    Is it possible that you’re hitting the GCD concurrent queue thread limit (64 threads), and then doing something that tries to do work on a concurrent queue? That would cause random deadlocks across the entire framework.

    If that’s the case, my only recommendation is: never block in a concurrent queue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using MACOS for Developing the iPhone Application. I have made the repository
I am developing Python application for Google App Engine on MacOS and I am
I'm developing an Android application on Eclipse Juno, and using a MAC OS Lion.
I'm developing a cocoa application. I'm using CIFilter, and CIImage for applying core concepts
I am developing an application using titanium mobile. On the simulator, the app works
I was developing an application using xcode 4 to target snow leopard (10.6) Now,
I am developing an iPhone application where I need to provide an animation which
I started developing my rails application using sqlite. I have reached a point where
I'm developing a Qt application on Mac OS X (Snow Leopard), which displays the
I am developing a Mac OS X application which, as part of it's UI,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.