(locals) gracefully handle binding error when on a Fiber #1095
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.
Description of the change
Background
TracePoint#binding
cannot be called from a Fiber, though I haven't seen anywhere that this is documented. This can be confirmed by reviewing the location where the exception is raised in Ruby:https://github.com/ruby/ruby/blob/744d17ff6c33b09334508e8110007ea2a82252f5/vm.c#L1240
And of course it can be confirmed by calling
binding
while on a Fiber. The above exception will be produced.In the reported issue, the error happens when
next
is called on anEnumerator
instance. Callingnext
causes execution to switch to a Fiber.https://github.com/ice-cube-ruby/ice_cube/blob/2cdfdbaf75bd809831df1af3f0e96639bbc69ee6/lib/ice_cube/schedule.rb#L217
When local variable capture is enabled in rollbar-gem, the stack frames within the Fiber context are captured. The reported issue happens because
TracePoint#binding
is called while capturing these frames.Fix
This PR rescues the failed attempt to get the binding and returns
nil
. Later when building the payload, it skips insertion of locals for frames where the binding is missing.Type of change
Related issues
Fixes: #1094
Development
Code review