JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-5044

JRuby throws invalid runtime exception when loading C extensions in different runtimes

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: JRuby 1.6.1
    • Component/s: Extensions
    • Labels:
      None
    • Environment:
      Applies to the cext branch
    • Number of attachments :
      0

      Description

      Many Rakefiles for C extensions will load a C extension and then try to exec a sub-ruby which also loads C extensions. This will fail in JRuby due to the two JRuby runtimes being executed on the same JVM. Maybe we could do a real fork in this particular case where the C extension support is already in use on this JVM.

        Activity

        Hide
        Tim Felgentreff added a comment -

        As headius suggested in IRC, we could also look into MVM on the C level and maybe see if C extensions might declare thread-safety, so we can decide whether to raise an InvalidRuntime on a per-extension basis.

        Show
        Tim Felgentreff added a comment - As headius suggested in IRC, we could also look into MVM on the C level and maybe see if C extensions might declare thread-safety, so we can decide whether to raise an InvalidRuntime on a per-extension basis.
        Hide
        Aman Gupta added a comment -

        To work around this issue, -Xlaunch.inproc=false or JRuby.runtime.instance_config.runRubyInProcess = false

        Show
        Aman Gupta added a comment - To work around this issue, -Xlaunch.inproc=false or JRuby.runtime.instance_config.runRubyInProcess = false
        Hide
        Tim Felgentreff added a comment -

        I know that's not what we want, but could we set runRubyInProcess to "false" once the first C extension is loaded, until we have a proper fix?

        Show
        Tim Felgentreff added a comment - I know that's not what we want, but could we set runRubyInProcess to "false" once the first C extension is loaded, until we have a proper fix?
        Hide
        Aman Gupta added a comment -

        +1 for setting inproc to false automatically.

        Show
        Aman Gupta added a comment - +1 for setting inproc to false automatically.
        Hide
        Charles Oliver Nutter added a comment -

        That's actually a great idea, Tim. I'll do that.

        Show
        Charles Oliver Nutter added a comment - That's actually a great idea, Tim. I'll do that.
        Hide
        Charles Oliver Nutter added a comment -

        I'm not sure of a great way to test this. It would probably be something in the cext tests that confirm a subprocess has run "actually" out of process. I'm going to go ahead with the fix assuming it works and then maybe poke at a test for it to night. Help there would be very welcome.

        Show
        Charles Oliver Nutter added a comment - I'm not sure of a great way to test this. It would probably be something in the cext tests that confirm a subprocess has run "actually" out of process. I'm going to go ahead with the fix assuming it works and then maybe poke at a test for it to night. Help there would be very welcome.
        Hide
        Charles Oliver Nutter added a comment -

        I consider this confirmation that it's working, but still need a test:

        ~/projects/jruby ➔ jruby --1.9 -e 'x = spawn "jruby -e sleep"; p x'
        513470641
        
        ~/projects/jruby ➔ jruby --1.9 -e 'require "rmagick"; x = spawn "jruby -e sleep"; p x'
        43567
        
        
        Show
        Charles Oliver Nutter added a comment - I consider this confirmation that it's working, but still need a test: ~/projects/jruby ➔ jruby --1.9 -e 'x = spawn "jruby -e sleep"; p x' 513470641 ~/projects/jruby ➔ jruby --1.9 -e 'require "rmagick"; x = spawn "jruby -e sleep"; p x' 43567
        Hide
        Charles Oliver Nutter added a comment -

        commit 9bc2e09d0c7aff683fc264c9407846c61d0092cc
        Author: Charles Oliver Nutter <headius@headius.com>
        Date: Wed Apr 6 00:25:00 2011 -0500

        Fix JRUBY-5044: JRuby throws invalid runtime exception when loading C extensions in different runtimes

        • Loading a C extension now disables in-process runtime launching, since it probably wouldn't work anyway.
        Show
        Charles Oliver Nutter added a comment - commit 9bc2e09d0c7aff683fc264c9407846c61d0092cc Author: Charles Oliver Nutter <headius@headius.com> Date: Wed Apr 6 00:25:00 2011 -0500 Fix JRUBY-5044 : JRuby throws invalid runtime exception when loading C extensions in different runtimes Loading a C extension now disables in-process runtime launching, since it probably wouldn't work anyway.

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Tim Felgentreff
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: