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

(master) frozen string errors with --debug #7924

Closed
flavorjones opened this issue Sep 4, 2023 · 3 comments · Fixed by #7928
Closed

(master) frozen string errors with --debug #7924

flavorjones opened this issue Sep 4, 2023 · 3 comments · Fixed by #7928
Milestone

Comments

@flavorjones
Copy link
Contributor

flavorjones commented Sep 4, 2023

Environment Information

Using jruby HEAD:

$ bin/jruby -v
jruby 9.4.4.0-SNAPSHOT (3.1.4) 2023-06-18 656f9d6570 OpenJDK 64-Bit Server VM 11.0.20.1+1-post-Ubuntu-0ubuntu122.04 on 11.0.20.1+1-post-Ubuntu-0ubuntu122.04 [x86_64-linux]

$ uname -a
Linux juno 6.2.0-1011-lowlatency #11~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Aug 16 16:22:57 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Reproduction

File foo.rb:

# frozen_string_literal: true

puts RUBY_DESCRIPTION

s = +"hello"
puts s.frozen?
s.force_encoding(::Encoding::ASCII_8BIT)

When run with bin/jruby foo.rb:

jruby 9.4.4.0-SNAPSHOT (3.1.4) 2023-06-18 656f9d6570 OpenJDK 64-Bit Server VM 11.0.20.1+1-post-Ubuntu-0ubuntu122.04 on 11.0.20.1+1-post-Ubuntu-0ubuntu122.04 [x86_64-linux]
false

When run with bin/jruby --debug foo.rb

jruby 9.4.4.0-SNAPSHOT (3.1.4) 2023-06-18 656f9d6570 OpenJDK 64-Bit Server VM 11.0.20.1+1-post-Ubuntu-0ubuntu122.04 on 11.0.20.1+1-post-Ubuntu-0ubuntu122.04 [x86_64-linux]
false
FrozenError: can't modify frozen String, created at foo.rb:5
  force_encoding at org/jruby/RubyString.java:6663
  force_encoding at org/jruby/RubyString.java:6659
          <main> at foo.rb:7

This error does not occur with jruby-9.4.2.0.

This was discovered by upstream nokogiri integration testing: https://github.com/sparklemotion/nokogiri/actions/runs/6076083505/job/16483500598

@flavorjones
Copy link
Contributor Author

I bisected, this behavior changed with 11418c3 /cc @headius

@ahorek ahorek added this to the JRuby 9.4.4.0 milestone Sep 4, 2023
@headius
Copy link
Member

headius commented Sep 5, 2023

Ahh good catch. The logic for +@ likely needs to be updated to check frozenness correctly. Interesting that this was not caught by any tests or specs but perhaps we exclude one that does.

headius added a commit to headius/jruby that referenced this issue Sep 8, 2023
No flag was set and nothing was overridden, so it did not appear
frozen via isFrozen checks. This caused jruby#7924.

The fix here both sets that flag and also overrides isFrozen to
always be true.

Fixes jruby#7924
@headius
Copy link
Member

headius commented Sep 8, 2023

Yeah oversight on my part... I overrode the RubyString.frozenCheck behavior, but did not actually mark the DebugFrozenString object as frozen itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants