semaphore: Bad file descriptor errors
I generally set semaphore: True in my cabal.project.local to speed up my builds. Occasionally, I see cabal build fail with messages like this:
semWaitInterrruptible: invalid argument (Bad file descriptor)
cabal_semaphore_3: semUnlink: does not exist (No such file or directory)
I'm afraid I don't have a reliable reproducer to share, but I didn't see any other issues in the tracker mentioning semaphores and bad file descriptors, so I figured I'd file this anyway just in case.
Expected behavior
The build simply completes, but faster than with semaphore: False.
System information
- macOS 15.5
cabal: 3.14.2.0ghc: 9.8.4
thanks for the report! tagging our semaphores guru @mpickering
I also sometimes see this right when starting a build, just after Cabal finishes planning:
Created semaphore called cabal_semaphore_3 with 14 slots.
cabal: semWait: invalid argument (Bad file descriptor)
Then cabal just hangs.
I've seen the same intermittent error, on macOS and on Ubuntu.
The question then becomes, is this the fault of cabal somehow, or is it a bug in semaphore-compat?
(It might be a manifestation of a bug in semaphore-compat as well, but) there is certainly a fault on Cabal side, because it should not fail hard but rather degrade gracefully to a non-semaphore mode.
Pinging @bgamari who added this support in #9139.
(of course, it's not exactly the best time for him…)
I see this error quite a bit on:
- macOS Tahoe 26.0.1
- cabal 3.14.2.0
- ghc 9.10.3