Skip to content
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

mprotect() SIGINT #152

Open
ashelkovnykov opened this issue Dec 1, 2023 · 3 comments
Open

mprotect() SIGINT #152

ashelkovnykov opened this issue Dec 1, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@ashelkovnykov
Copy link
Collaborator

The current implementation of handling SIGINT signals in Ares from king sets a sentinel value which is polled on every call to Nock 2, Nock 9, and push to mean stack. If the sentinel value is set, the event bails with a non-deterministic error. If the sentinel value is already set when the user attempts to set it again, the serf process exits.

An alternative solution is to mprotect() the entire NockStack on SIGINT. The next access will hit SIGSEGV, from where we can un-protect the NockStack memory and bail with a non-deterministic error. A second call to SIGINT while the region is already mprotect()ed will kill the serf process.

@eamsden
Copy link
Collaborator

eamsden commented Dec 16, 2023

@ashelkovnykov how hard would this be to implement on top of what you've done for bail:meme?

@eamsden
Copy link
Collaborator

eamsden commented Dec 16, 2023

This would remove the need to check the TERMINATOR static flag on every 2 and 9. Instead, if an error was returned from the hw_exception::catch block in the interpreter, we could just return bail:alrm.

@matthew-levan matthew-levan linked a pull request Jan 16, 2024 that will close this issue
2 tasks
@ashelkovnykov
Copy link
Collaborator Author

This should be pretty easy now that we have the C signal handler code for the guard page: just need to add some more handlers in the same lib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Post-release
Development

Successfully merging a pull request may close this issue.

2 participants