-
Notifications
You must be signed in to change notification settings - Fork 74
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
Forbid SIGBUS #139
base: master
Are you sure you want to change the base?
Forbid SIGBUS #139
Conversation
SIGBUS is similar to SIGSEGV in regards to when it is raised and the sort of special handling required for recovery.
Hello I understand the argument. Nevertheless, this would be a breaking change and it doesn't seem worth doing a „big version“ jump because of that. Let me note, however, that:
Which leads me to the detail that you could (maybe, depending on what you do?) use signal-hook-registry's register_sigaction_unchecked as your backend, to a) avoid dealing with some of the stuff (unlikely to be the bigger part of the problem in your case, to be fair), b) potentially multiplex the signals. What is it you're actually planning on doing with the signal in the I would be OK with adding a documentation note that |
So, there are basically two ways of dealing with page faults which don't involve terminating the program:
I want to support both use cases but my interest is mainly in the second. There will be two parts to the crate's API. One will look like
The second part of the API will be a Anyway, this brings me to the problem with |
Perhaps a backward-compatible way out here is add a new low-level call to |
🤔 This approach seems rather fragile. I mean, we can set up some protocol to talk between these two crates, like the exclusive flag you mentioned. But that doesn't stop some third crate we don't know about from messing with the signal handler. And I'm a bit reluctant to pollute the crate with more functionality (I've had some more bigger plans around that, what I'm not sure how this fits together) and I don't really have much time to think about these things. But I wonder if it was possible to check for the exclusivity on your side. Considering someone can do the classical chaining of signal handlers (as does signal-hook, but independently) after you check exclusivity and register, it would have to happen both during your registration and during the signal handler, but something like this might work:
Would that thing work? I haven't checked this in practice / against the spec that this is fully supported everywhere, though. |
Nevertheless, you make a point that SIGBUS is, in fact, a signal somewhat dangerous to mess with. I'll have to think about what are the (safety / soundness) implications with eg. „safely“ replacing the default handler with eg. setting a boolean flag. |
Sure, but since nothing in
No, this wouldn't work. Unsafe code needs to know before it causes a segfault what the signal handler is going to do with it. Checking that before every operation would be both racy and prohibitively expensive. |
I'm simply wondering. Your crate will be offering a safe interface to do your thing. That third party crate would be offering a safe interface. But if put together, they could cause UB. So, which one of them would be unsound? Anyway, I'm going to think about some future-proof API of incorporating both claiming of the signals and the stuff hinted at in #82. The problems is, I don't really have the time to write the code right now. So, I can sketch the API and the ideas behind it, but would probably need someone to do the coding. |
That's the trouble with global state — there's no meaningful answer to this question. If we wanted to reason about this formally using separation logic, we'd want to construct a frame of everything that interacts with signal handler state, and ask whether the frame is sound. But we don't know what's in that frame until we link the whole program together. |
I've released the pagefault crate, under the (more accurate) name |
SIGBUS is similar to SIGSEGV in regards to when it is raised and the sort of special handling required for recovery.
I'm planning (haven't started) a
pagefault
crate specifically designed for handling SIGSEGV and SIGBUS, and want to avoid stepping on each other's toes.