-
Notifications
You must be signed in to change notification settings - Fork 185
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
rb_str_locktmp: raises when called on a Frozen String #3752
Comments
It's from truffleruby/src/main/java/org/truffleruby/cext/CExtNodes.java Lines 972 to 976 in c229bfd
From a very quick look the error is because rb_str_locktmp() is called on a truly-immutable string (e.g. a frozen string literal or String#-@ or Symbol#name ).That means it shouldn't have state, which also means it shouldn't be possible to lock it. Isn't string locking meant to avoid concurrent modifications to a string and so shouldn't be done if the string is frozen or indicates a bug in the caller (trying to mutate a frozen string)? rb_str_locktmp() could be noop for immutable strings, but is that correct? If something queries whether it's locked then it wouldn't reflect it. |
Yeah, not too sure. We probably should add some specs after that. IMO it would be OK for |
Probably we should ask on https://bugs.ruby-lang.org/. I also wonder if as a side effect of rb_str_locktmp(frozen_string), trying to mutate that frozen string raises another error and not the correct FrozenError. |
Why, because locking it would mutate its flags? I think that's OK. I wouldn't be a big fan of such precondition, because that just means |
I filed https://bugs.ruby-lang.org/issues/20998 |
Keeping this open to track what's decided on the CRuby issue, and also because we should behave the same for ImmutableRubyString and frozen-but-not-ImmutableRubyString strings. |
Ref: ruby/openssl#831
Whereas MRI doesn't care whether the string is frozen or not, it will lock it either way:
cc @eregon @nirvdrum
The text was updated successfully, but these errors were encountered: