Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentError: negative string size (or size too big) for rb_enc_left_char_head() #3267

Closed
eregon opened this issue Sep 20, 2023 · 1 comment
Assignees
Labels

Comments

@eregon
Copy link
Member

eregon commented Sep 20, 2023

Found by @segiddins and reported on the Bundler Slack:

rb_enc_left_char_head has length = start - end which will always be negative, and results in an exception in the call to rb_str_new for passing a negative length, and it probably should be length = end - start

And indeed adding a C API spec for it I can confirm:

C-API Encoding function rb_enc_left_char_head returns the head position of a character ERROR
ArgumentError: negative string size (or size too big)
/home/eregon/code/truffleruby-ws/graal/sdk/mxbuild/linux-amd64/GRAALVM_3555B82685_JAVA21/graalvm-3555b82685-java21-24.0.0-dev/languages/ruby/lib/truffle/truffle/cext.rb:1138:in `rb_exc_raise'
/home/eregon/code/truffleruby-ws/truffleruby/src/main/c/cext/exception.c:29:in `rb_exc_raise'
/home/eregon/code/truffleruby-ws/truffleruby/src/main/c/cext/string.c:52:in `rb_str_new'
/home/eregon/code/truffleruby-ws/truffleruby/src/main/c/cext/encoding.c:232:in `rb_enc_left_char_head'
encoding_spec.c:312:in `encoding_spec_rb_enc_left_char_head'
/home/eregon/code/truffleruby-ws/graal/sdk/mxbuild/linux-amd64/GRAALVM_3555B82685_JAVA21/graalvm-3555b82685-java21-24.0.0-dev/languages/ruby/lib/truffle/truffle/cext_ruby.rb:42:in `rb_enc_left_char_head'
/home/eregon/code/truffleruby-ws/truffleruby/spec/ruby/optional/capi/encoding_spec.rb:679:in `block (3 levels) in <top (required)>'
/home/eregon/code/truffleruby-ws/truffleruby/spec/ruby/optional/capi/encoding_spec.rb:42:in `<top (required)>'
@eregon eregon added the bug label Sep 20, 2023
@eregon eregon self-assigned this Sep 20, 2023
graalvmbot pushed a commit that referenced this issue Sep 20, 2023
PullRequest: truffleruby/4013
mtortonesi pushed a commit to mtortonesi/truffleruby that referenced this issue Nov 10, 2023
@eregon
Copy link
Member Author

eregon commented Dec 4, 2023

This fix will be in the 23.1.2 release which will be available on January 23, 2024.

graalvmbot pushed a commit that referenced this issue Dec 7, 2023
PullRequest: truffleruby/4013
(cherry picked from commit c77f8bb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant