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.
This is a fix for #145, handling
exec
calls, for Linux. While the same approach should work for MacOS, extra work would be needed to distinguish between invalid reads and process exit and since I've already let this sit for many months, I'd prefer to land Linux support.The idea here is to check the result returned when getting the stack trace from the target process to detect the error that the pointer to the ruby thread state, specifically, has become invalid. If it has, we then reinitialize StackTraceGetter on the basis that if we've lost the thread the whole process is invalid.
In the test case I added I'm polling until the reinitialization happens. I did this because when I used a fixed timeout I was sometimes getting the trace before reinitialization (one every 500 test runs or so), and I didn't want to play the timeout tweaking game. With the current polling I still get the error "stack base and cfp address out of sync" once every few thousand test runs but I think that error should be transient and shouldn't impact real usage.