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

MPS signal handlers might modify errno #10

Closed
gareth-rees opened this issue Aug 23, 2020 · 0 comments · Fixed by #32
Closed

MPS signal handlers might modify errno #10

gareth-rees opened this issue Aug 23, 2020 · 0 comments · Fixed by #32
Assignees
Labels
bug It's very unclear what this means. Avoid.

Comments

@gareth-rees
Copy link
Member

gareth-rees commented Aug 23, 2020

On Posix operating systems (FreeBSD and Linux), the MPS handles barrier hits, and suspends and resumes threads, by installing signal handlers with sigaction(). The signal handlers may call libc functions like mprotect(), mmap() and so on, that set errno.

The Posix specification for sigaction() says:

Note in particular that even the "safe" functions may modify errno; the signal-catching function, if not executing as an independent thread, should save and restore its value in order to avoid the possibility that delivery of a signal in between an error return from a function that sets errno and the subsequent examination of errno could result in the signal-catching function changing the value of errno.

This applies to the following signal handlers:

  1. sigHandle() in protsgix.c
  2. suspendSignalHandler() in pthrdext.c
  3. resumeSignalHandler() in pthrdext.c (this can in theory call mps_lib_assert_fail() if the assertion fails, and in the hot and rash varieties the application can continue from the assertion failure)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It's very unclear what this means. Avoid.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant