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

JVM crash while running rails app on Torquebox from com.kenai.jffi.Foreign.getZeroTerminatedByteArray

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.6.7
    • Fix Version/s: JRuby 1.7.0.pre1
    • Component/s: C Extensions
    • Labels:
    • Environment:
      Red Hat Enterprise Linux Server release 6.2 (Santiago) 64bit
      jruby 1.6.7 (ruby-1.9.2-p312) (2012-02-22 3e82bc8) (OpenJDK 64-Bit Server VM 1.6.0_22) [linux-amd64-java]
    • Number of attachments :
      1

      Description

      Running a rails app in Torquebox 2.0.1 occasionally results in a jvm crash.

        Activity

        Hide
        Wayne Meissner added a comment -

        I think this is due to jnr-netdb's usage of getservbyport, which on linux, is not threadsafe.

        This was fixed in the most recent jnr-netdb, but has not been backported to jruby-1.6. You could possibly grab the build_lib/jnr-netdb.jar from jruby master, drop it into a jruby-1.6 tree and rebuild, and everything would work. Worth a try at least.

        Show
        Wayne Meissner added a comment - I think this is due to jnr-netdb's usage of getservbyport, which on linux, is not threadsafe. This was fixed in the most recent jnr-netdb, but has not been backported to jruby-1.6. You could possibly grab the build_lib/jnr-netdb.jar from jruby master, drop it into a jruby-1.6 tree and rebuild, and everything would work. Worth a try at least.
        Hide
        Jeff Cantrill added a comment -

        It was suggested to me the following would also resolve the code, but I'm not sure how I would integrate this or if it is even worth it if there is another fix:

        require 'socket'
        require 'thread'

        class << Socket
        GETSERVBYNAME_GUARD = Mutex.new
        alias orig_getservbyname getservbyname
        def getservbyname(*a)
        GETSERVBYNAME_GUARD.synchronize

        { orig_getservbyname(*a) }

        end
        end

        Show
        Jeff Cantrill added a comment - It was suggested to me the following would also resolve the code, but I'm not sure how I would integrate this or if it is even worth it if there is another fix: require 'socket' require 'thread' class << Socket GETSERVBYNAME_GUARD = Mutex.new alias orig_getservbyname getservbyname def getservbyname(*a) GETSERVBYNAME_GUARD.synchronize { orig_getservbyname(*a) } end end
        Hide
        Charles Oliver Nutter added a comment -

        If that workaround works, you'd want to include it somewhere in your app before you actually call getservbyname. It may indeed be sufficient.

        Can you confirm that it is fixed on master, at least? I'm going to mark this resolved in 1.7 for now...

        Show
        Charles Oliver Nutter added a comment - If that workaround works, you'd want to include it somewhere in your app before you actually call getservbyname. It may indeed be sufficient. Can you confirm that it is fixed on master, at least? I'm going to mark this resolved in 1.7 for now...

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Jeff Cantrill
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: