reactor: more info, robustness on segfault #2691
Closed
+50
−4
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.
On segfault we execute a handler that provides information including a backtrace. This currently emits all information in a single write call after collecting it in a buffer. If anything goes wrong, e.g., the backtrace() call itself crashes, then no information will be emitted. The backtrace() call is not signal safe in theory, and in practice the situation seems mixed as to its safety. So it not unlikely that situations may arise where no output can be emitted on SIGSEGV.
Because we catch the signal and then re-raise it using pthread_kill, the specific information about the IP is lost in re-raise: this prevents the line in syslog which usually captures information about segfaults from appearing at all. So we may be left without useful information after a crash.
In this change, we emit additional information before the backtrace() which is not likely to have any problem, and we emit each as separate write(2) calls so if there is a failure at any point we at least have the information emitted up to that point.
After this, the start of the output on segfault looks like so: