Skip to content

cabal-install 3.6 on OSX doesn't handle ctrl-c (interrupts) correctly #8078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cartazio opened this issue Apr 2, 2022 · 12 comments
Closed

Comments

@cartazio
Copy link
Contributor

cartazio commented Apr 2, 2022

Describe the bug
ctr+c should trigger a CLI application to start a clean shutdown process for the overall cli invocation, not for its many subtasks

To Reproduce
Steps to reproduce the behavior:

cabal install pandoc # on a machine with no build cache
# wait for it to be midway into downloading a dozen plus packages
ctrl+c
# see it just cancels stuff for just one sub task, not everything else
do control c again
# notice it just cancels another task
# start trying harder cmands that send more aggressive interrupts

Please use version-prefixed commands (e.g. v2-build or v1-build) to avoid ambiguity.

Expected behavior
A clear and concise description of what you expected to happen.

ctrl c should start the shutdown of the build!
I think this used to work correctly?

System information

  • Operating system M1 pro OSX mac,
  • cabal, ghc versions ghc 9.2.2 ARM64, cabal 3.6

Additional context
i think what might be happening is that the sub computations register their own interrupt handles to the OS and somehow those are picked up? i cant im

@hasufell
Copy link
Member

hasufell commented Apr 2, 2022

@robx is our process handling expert

@cartazio
Copy link
Contributor Author

cartazio commented Apr 2, 2022

it might be a problem related to how downloads are managed (private chat with @hasufell ), but either way, its not an area of cabal i'm familiar with, and it hints at some sort of serious architectural issues in how interrupts are registered and handled.

@hasufell
Copy link
Member

hasufell commented Apr 2, 2022

Maybe it is already fixed #7929

@cartazio
Copy link
Contributor Author

cartazio commented Apr 2, 2022

a secondary thing is doing ctrl z may not have actually stopped the child package jobs from building? (or i just dont understand control z)

@cartazio
Copy link
Contributor Author

cartazio commented Apr 3, 2022

it would be nice if this was shipped in a bug fix release or something... its kinda important user facing behavior :)

i'll poke at it more and see if master is better behaved..

@cartazio
Copy link
Contributor Author

cartazio commented Apr 3, 2022

@jneira i'd be surprised if the bug didnt show up on other platforms

@robx
Copy link
Collaborator

robx commented Apr 4, 2022

Yeah this particular bug should be fixed in master.

Regarding Ctrl-C handling, what happens is

  • the shell sends SIGINT to the whole process group (all children)
  • Haskell's runtime by default converts SIGINT to a UserInterrupt async exception thrown at the main thread (or at least that's my working mental model)
  • however, we spawn subprocesses using so called "Ctrl-C delegation", which means that we ignore SIGINT while a subprocess is running, and raise UserInterrupt when that subprocess exits due to the SIGINT it received

(compare https://hackage.haskell.org/package/process-1.6.13.2/docs/System-Process.html#g:4)

(I have no idea at this point of whether Ctrl-Z works reasonably.)

@jneira
Copy link
Member

jneira commented Apr 4, 2022

@jneira i'd be surprised if the bug didnt show up on other platforms

yeah, it somewhat works in master thanks to #7929 and the main process is killed immediately but it lefts orphan subprocess as #7921 did not fix that for windows (but it did for other platforms afaik)

so maybe we could remove the tag and rename the issue to remove the macos mention

@robx
Copy link
Collaborator

robx commented Apr 4, 2022

I think as bug report, this is a duplicate of #6322.

@jneira
Copy link
Member

jneira commented Apr 4, 2022

oh yeah, good catch, @cartazio does that previous bug report represent yours enough to close this?

@cartazio
Copy link
Contributor Author

cartazio commented Apr 4, 2022

yeah, sounds like the same bug,
any remainder things that need an extra pair of eyes?

also is there any chance that there could be a bugfix release with this?

@jneira
Copy link
Member

jneira commented Apr 4, 2022

re processes there are another pending pr: #7757, maybe we could work on it
if you dont mind i am gonna close this one, feel free to comment here or in #6322

@jneira jneira closed this as completed Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants