cabal icon indicating copy to clipboard operation
cabal copied to clipboard

semaphore: Bad file descriptor errors

Open langston-barrett opened this issue 4 months ago • 8 comments

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.0
  • ghc: 9.8.4

langston-barrett avatar Jul 30 '25 14:07 langston-barrett

thanks for the report! tagging our semaphores guru @mpickering

ulysses4ever avatar Jul 30 '25 15:07 ulysses4ever

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.

langston-barrett avatar Jul 31 '25 20:07 langston-barrett

I've seen the same intermittent error, on macOS and on Ubuntu.

Bodigrim avatar Jul 31 '25 20:07 Bodigrim

The question then becomes, is this the fault of cabal somehow, or is it a bug in semaphore-compat?

geekosaur avatar Jul 31 '25 20:07 geekosaur

(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.

Bodigrim avatar Jul 31 '25 20:07 Bodigrim

Pinging @bgamari who added this support in #9139.

geekosaur avatar Jul 31 '25 20:07 geekosaur

(of course, it's not exactly the best time for him…)

geekosaur avatar Jul 31 '25 20:07 geekosaur

I see this error quite a bit on:

  • macOS Tahoe 26.0.1
  • cabal 3.14.2.0
  • ghc 9.10.3

wraithm avatar Oct 14 '25 17:10 wraithm