Repository navigation
Conversation
A range whose endpoints are both literals became a Range operand, which is built wherever its value is used rather than where it appears. But a range of incomparable literals like 1.."3" raises ArgumentError when it's built, so it raised in the wrong place. As the value of a begin body it raised after the rescue region, so the rescue never ran. As the value of a compiled block under --debug, it raised after the block had popped its frame, and the block's exception handler popped the frame again. That frame leak is what has been crashing test:mri:core:jit since jruby#9838 let blocks like { (1.."3") } in test_range.rb compile: test-unit's at_exit block runs out of frames and fails with ArrayIndexOutOfBoundsException. Only make a Range operand when building it can't raise: when an endpoint is nil, or both are real numbers, strings or symbols. Anything else is built by a BuildRangeInstr where it appears.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 fixes the
test:mri:core:jitfailures on master since #9838. All the tests pass, but then test-unit'sat_exitblock crashes withArrayIndexOutOfBoundsException: Index -1inThreadContext#getNextFrame.A range whose endpoints are both literals becomes a
Rangeoperand, which gets built wherever its value is used rather than where it appears. That's fine for1..10or"a".."z", but a range of incomparable literals like1.."3"raisesArgumentErrorwhen it's built, so it raises in the wrong place:The range is the value of the
beginbody, so it's built after the rescue region and the rescue never runs. That happens in every mode and goes back at least to 10.1.2.0.The same thing in a compiled block is worse with
-Xdebug.fullTrace, which the MRI test tasks use. The block's IR ends withpop_block_framefollowed byreturn(rng<Fixnum:1..frozen:"3">), so the range raises after the frame is popped, and the global ensure block pops it again.test_range.rbhasassert_raise(ArgumentError) { (1.."3") }intest_new, which leaks one frame each time it runs. Those blocks couldn't be compiled before #9838, which is why this only started then. It doesn't show up without full tracing, which is why I couldn't reproduce it locally at first.This only makes a
Rangeoperand when building it can't raise: when an endpoint isnil, or both are real numbers, strings or symbols. Anything else, like1.."3",:a..1ortrue..false, is built by aBuildRangeInstrwhere it appears.The new spec in
general_spec.rbfails in all four modes before this change and passes after it. With CI's exact options,rake test:mri:core:jitpasses locally with no crash, and the compiler specs pass with and without invokedynamic.