Skip to content

Shutdown interacts badly with requestSync()

I've been investigating #10860 (closed), and the problem goes pretty deep, so I'm going to record what I know here and come back to fix it properly later.

We have this mechanism requestSync() for operations that need to seize control of the whole runtime to do something. It is used by

  • scheduleDoGC()
  • setNumCapabilities()
  • forkProcess()

requestSync() ensures that only one of these operations wins, the others will yieldCapability() to the winner, before continuing with their own sync.

The problem is that this interacts badly with shutdown. Shutdown might start at any time (initiated by exitScheduler()). If it starts during a sync, then a deadlock is likely: some capabilities will be already shut down, and cannot be acquired by acquireAllCapabilities(). This happens in #10860 (closed).

Really, shutdown should play the requestSync() game too, but that requires a lot of thought.

Edited by Simon Marlow
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information