Fix index -1 error while searching for feature path#8961
Merged
headius merged 1 commit intojruby:jruby-9.4from Aug 14, 2025
Merged
Fix index -1 error while searching for feature path#8961headius merged 1 commit intojruby:jruby-9.4from
headius merged 1 commit intojruby:jruby-9.4from
Conversation
The code here is intended to walk the incoming feature, looking for either '.' or '/' in order to break up the feature into a path and filename. This is then compared with the load path to find a match, indicating that the feature has been loaded via those paths. The bug is that it should find one of those characters or leave the search index 'e' at the beginning of the feature string for a subsequent check, but it was ported incorrectly from the original C code. Index of stopping at the beginning of the string, it allows one more decrement leaving 'e' as -1, and String.charAt raises. This is normally only triggered for features that are being required at the same time across threads, and which have not yet been expanded to their full load path form. With the unexpanded feature in flight, the search will never encounter '.' or '/' and walk off the head of the string. Fixes jruby#8958
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.
The code here is intended to walk the incoming feature, looking for either '.' or '/' in order to break up the feature into a path and filename. This is then compared with the load path to find a match, indicating that the feature has been loaded via those paths.
The bug is that it should find one of those characters or leave the search index 'e' at the beginning of the feature string for a subsequent check, but it was ported incorrectly from the original C code. Index of stopping at the beginning of the string, it allows one more decrement leaving 'e' as -1, and String.charAt raises.
This is normally only triggered for features that are being required at the same time across threads, and which have not yet been expanded to their full load path form. With the unexpanded feature in flight, the search will never encounter '.' or '/' and walk off the head of the string.
Fixes #8958
Backport of #8960