-
Notifications
You must be signed in to change notification settings - Fork 163
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
Reinstall GAP SIGINT handler when Julia is started #3256
Open
sebasguts
wants to merge
1
commit into
gap-system:master
Choose a base branch
from
sebasguts:sg/reenable_signal_handling_julia_gc
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, so let's see, this is the code for
SyInstallAnswerIntr
:This doesn't do anything if there already is a
SIGINT
handler installed, does it? But doesn't Julia install a SIGINT handler? Since I assume you tested this, the answer seems to be no; yet Julia'sdoc/src/devdocs/init.md
says this:Digging some more into
signal-unix.c
also reveals this:Which suggests to me that it does handle
SIGINT
, just not viasignal()
but rather viasigprocmask
...(Funny story on the side: On macOS, the relevant C file is
signals-mach.c
, which also defines e.g.static void jl_try_deliver_sigint()
, but never calls it, and seems to contain no provisions at all to handleSIGINT
?!? And finallysignals-win.c
does have some, but written in a completely different style?!?). Of courselibuv
might also be involved somehow?All of this is to say: I don't quite understand why the above works; and I am slightly worried that it might cause unexpected problems... Like, what happens if our custom SIGINT handler is triggered while we are inside Julia code? Could this leave Julia in an undefined state?
So I guess what I'd like to know is what kind of tests you performed with this modified code... Like, I assume if one starts GAP and loads JuliaInterface in it, but does not use it, everything works fine (Ctrl-C in GAP code enters a break loop). Correct? And what happens if one presses Ctrl-C while Julia code is running? And what happens when one starts Julia and loads GAPJulia, and then presses Ctrl-C, either while Julia code is running, or while GAP code is running? (And I guess ultimately, we also need to think about more deeply nested callchains with ...->GAP code->Julia code->GAP->Julia->...)
None of this is meant to kill of this PR, I simply would like to understand better what it does and why it works, and then perhaps we can put some of it in a comment and/or the commit message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One problem that you may be running into is that on macOS, Julia does not install a signal handler, but goes directly for the Mach system calls. When they do that, normal signal handling is subsequently ignored. There are ways to insert yourself in the signal handling process in Julia, but I haven't delved too deep into those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that
signals-mach.c
is included bysignals-posix.c
, and now feel dumb for not considering this possibility earlier 🤣