Prefer userfaultfd over mprotect+SIGSEGV signal handling on linux for phpdbg watchpoints #7551
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.
Not sure whether that's a good idea, especially unsure whether config.m4 check for userfault handling is fine. The problem with a classical "program" check where we run userfaultfd() and an ioctl() is that userfaultfd(2) may error if the user building phpdbg is not permitted to use the syscall (like it may be the case in docker - or as unprivileged user on a hardened system).
This also is much more compatible with gdb for debugging purposes (I intend on improving stability and memory leaks here in future commits...). In general, this approach seems also to be strongly recommended in Linux over the classical mprotect+SIGSEGV handling (https://www.kernel.org/doc/Documentation/vm/userfaultfd.txt).