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

JRuby 9.1.0.0 on Windows causes frozen string errors when using rake and minitest #3855

Closed
jeremyevans opened this issue May 5, 2016 · 6 comments

Comments

@jeremyevans
Copy link
Contributor

Basically, running jruby 9.1.0.0 from the command line in Windows works correctly. However, when using rake's sh method the same command line breaks with a frozen string error.

Because of this issue, I can't run Sequel's specs using rake with JRuby 9.1.0.0 on Windows.

Environment

jruby 9.1.0.0 (2.3.0) 2016-05-02 a633c63 Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b15 +jit [mswin32-x86_64]

Expected Behavior

>C:/jruby-9.1.0.0/bin/jruby.exe -ve "require 'minitest/autorun'"
jruby 9.1.0.0 (2.3.0) 2016-05-02 a633c63 Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b15 +jit [mswin32-x86_64]
io/console not supported; tty will not be manipulated
Run options: --seed 28803

# Running:



Finished in 0.017170s, 0.0000 runs/s, 0.0000 assertions/s.

0 runs, 0 assertions, 0 failures, 0 errors, 0 skips
>type Rakefile
task :default do
  sh "#{FileUtils::RUBY} -ve \"require 'minitest/autorun'\""
end
>C:/jruby-9.1.0.0/bin/jruby.exe -S rake
C:/jruby-9.1.0.0/bin/jruby.exe -ve "require 'minitest/autorun'"
jruby 9.1.0.0 (2.3.0) 2016-05-02 a633c63 Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b15 +jit [mswin32-x86_64]
io/console not supported; tty will not be manipulated
Run options: --seed 28803

# Running:



Finished in 0.017170s, 0.0000 runs/s, 0.0000 assertions/s.

0 runs, 0 assertions, 0 failures, 0 errors, 0 skips

Actual Behavior

>C:/jruby-9.1.0.0/bin/jruby.exe -S rake
C:/jruby-9.1.0.0/bin/jruby.exe -ve "require 'minitest/autorun'"
jruby 9.1.0.0 (2.3.0) 2016-05-02 a633c63 Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b15 +jit [mswin32-x86_64]
io/console not supported; tty will not be manipulatedRuntimeError: can't modify frozen String
    <top> at C:/jruby-9.1.0.0/lib/ruby/stdlib/rubygems/user_interaction.rb:11
  require at org/jruby/RubyKernel.java:944
    <top> at C:/jruby-9.1.0.0/lib/ruby/stdlib/rubygems/config_file.rb:1
  require at org/jruby/RubyKernel.java:944
    <top> at C:/jruby-9.1.0.0/lib/ruby/stdlib/rubygems/config_file.rb:8
  require at org/jruby/RubyKernel.java:944
    <top> at C:/jruby-9.1.0.0/lib/ruby/stdlib/rubygems/defaults/jruby.rb:1
  require at org/jruby/RubyKernel.java:944
    <top> at C:/jruby-9.1.0.0/lib/ruby/stdlib/rubygems/defaults/jruby.rb:1
     load at org/jruby/RubyKernel.java:962
    <top> at C:/jruby-9.1.0.0/lib/ruby/stdlib/rubygems.rb:1
rake aborted!
Command failed with status (1): [C:/jruby-9.1.0.0/bin/jruby.exe -ve "requir...]
L:/jrubytest/rakefile:2:in `block in (root)'
Tasks: TOP => default
(See full trace by running task with --trace)
@kerbo
Copy link

kerbo commented May 6, 2016

I'm having the same problem with RubyMine. Rails won't start.

@headius
Copy link
Member

headius commented May 9, 2016

Ignore those commits; they were for another bug and have been force-pushed to fix the bad reference.

@headius
Copy link
Member

headius commented May 11, 2016

Looking into this one today.

@headius headius self-assigned this May 11, 2016
@headius
Copy link
Member

headius commented May 11, 2016

Relevant portion of the Java trace. It's an IO#puts call triggering the error.

        frozenCheck at org/jruby/RubyString.java:890
        modifyCheck at org/jruby/RubyString.java:878
               view at org/jruby/RubyString.java:1001
           setValue at org/jruby/RubyString.java:5440
        doWriteconv at org/jruby/util/io/OpenFile.java:2080
             fwrite at org/jruby/util/io/OpenFile.java:2036
              write at org/jruby/RubyIO.java:1437
              write at org/jruby/RubyIO.java:1409
            finvoke at org/jruby/RubyClass.java:770
             invoke at org/jruby/runtime/Helpers.java:403
         callMethod at org/jruby/RubyBasicObject.java:385
              write at org/jruby/RubyIO.java:2546
     writeSeparator at org/jruby/RubyIO.java:2489
              puts0 at org/jruby/RubyIO.java:2440
               puts at org/jruby/RubyIO.java:2416

@headius
Copy link
Member

headius commented May 11, 2016

I think I see it; it appears that the logic for transcoding written strings before writing them attempts to replace the contents of the original string. Because we reuse the same frozen string for \n in puts calls, it blows up trying to transcode that.

Fix shortly. No workaround I'm afraid.

@headius
Copy link
Member

headius commented May 11, 2016

And a trivial reproduction for anyone curious:

$ jruby -e "File.open('/tmp/blah.txt', 'w', newline: :crlf) {|f| f.puts}"
RuntimeError: can't modify frozen String
        write at org/jruby/RubyIO.java:1437
        write at org/jruby/RubyIO.java:1409
        write at org/jruby/RubyIO.java:2546
         puts at org/jruby/RubyIO.java:2416
  block in -e at -e:1
         open at org/jruby/RubyIO.java:1131
        <top> at -e:1

I will turn this into a RubySpec.

headius added a commit that referenced this issue May 11, 2016
Added to address a frozen string bug #3855.
eregon pushed a commit to ruby/spec that referenced this issue May 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants