Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.6
    • Fix Version/s: JRuby 1.7.0.RC1
    • Component/s: IBM/Other VM
    • Labels:
      None
    • Environment:
    • Number of attachments :
      0

      Description

      Running various commands and scripts it appears that they complete however the last line is "Segmentation fault". I can reproduce this by running various gem commands and warbler as well. See below for an example. There are no core dumps created and the commands complete fairly quickly so I haven't been able to pull off a threadump.

      $ gem help commands
      GEM commands are:

      build Build a gem from a gemspec
      cert Manage RubyGems certificates and signing settings
      check Check installed gems
      cleanup Clean up old versions of installed gems in the local
      repository
      contents Display the contents of the installed gems
      dependency Show the dependencies of an installed gem
      environment Display information about the RubyGems environment
      fetch Download a gem and place it in the current directory
      generate_index Generates the index files for a gem server directory
      help Provide help on the 'gem' command
      install Install a gem into the local repository
      list Display gems whose name starts with STRING
      lock Generate a lockdown list of gems
      outdated Display all gems that need updates
      owner Manage gem owners on RubyGems.org.
      pristine Restores installed gems to pristine condition from files
      located in the gem cache
      push Push a gem up to RubyGems.org
      query Query gem information in local or remote repositories
      rdoc Generates RDoc for pre-installed gems
      search Display all gems whose name contains STRING
      server Documentation and gem repository HTTP server
      sources Manage the sources and cache file RubyGems uses to search
      for gems
      specification Display gem specification (in yaml)
      stale List gems along with access times
      uninstall Uninstall gems from the local repository
      unpack Unpack an installed gem to the current directory
      update Update the named gems (or all installed gems) in the local
      repository
      which Find the location of a library file you can require

      For help on a particular command, use 'gem help COMMAND'.

      Commands may be abbreviated, so long as they are unambiguous.
      e.g. 'gem i rake' is short for 'gem install rake'.
      Segmentation fault

        Activity

        Hide
        Marc D'Arcy added a comment -

        The issue looks to be caused by the JFFI library used by JRuby.

        The library calls pthread_key_create(pthread_key_t key, void (*destructor)(void)); from its JNI_OnLoad() method to create some kind of thread-specific data. The destructor is a function defined in the shared library.

        The jvm appropriately attempts to free resources allocated in classloaders at shutdown, resulting in the library being unloaded. When the destructor is then called during thread exit, the segv occurs since the library providing the instructions for the function has been unloaded.

        This situation occurs because the jffi library is missing the appropriate JNI_OnUnload method and call to pthread_key_delete to remove the value destructor which was added using pthread_key_create().

        Ref.1: http://download.oracle.com/javase/6/docs/technotes/guides/jni/spec/invocation.html#JNI_OnUnload
        Ref.2: http://pubs.opengroup.org/onlinepubs/009604499/functions/pthread_key_delete.html

        I'm happy to run tests against a JRuby build with included fixes to verify correct operation.

        Show
        Marc D'Arcy added a comment - The issue looks to be caused by the JFFI library used by JRuby. The library calls pthread_key_create(pthread_key_t key, void (*destructor)(void )); from its JNI_OnLoad() method to create some kind of thread-specific data. The destructor is a function defined in the shared library. The jvm appropriately attempts to free resources allocated in classloaders at shutdown, resulting in the library being unloaded. When the destructor is then called during thread exit, the segv occurs since the library providing the instructions for the function has been unloaded. This situation occurs because the jffi library is missing the appropriate JNI_OnUnload method and call to pthread_key_delete to remove the value destructor which was added using pthread_key_create(). Ref.1: http://download.oracle.com/javase/6/docs/technotes/guides/jni/spec/invocation.html#JNI_OnUnload Ref.2: http://pubs.opengroup.org/onlinepubs/009604499/functions/pthread_key_delete.html I'm happy to run tests against a JRuby build with included fixes to verify correct operation.
        Hide
        Geraint Jones added a comment -

        Is there a JRuby build that includes fixes for this? I'd like to run the JRuby tests to verify that the fixes work.

        Show
        Geraint Jones added a comment - Is there a JRuby build that includes fixes for this? I'd like to run the JRuby tests to verify that the fixes work.
        Hide
        Charles Oliver Nutter added a comment -

        Can you try one of the snapshot nightly builds from http://ci.jruby.org/snapshots/?

        Show
        Charles Oliver Nutter added a comment - Can you try one of the snapshot nightly builds from http://ci.jruby.org/snapshots/?
        Hide
        Charles Oliver Nutter added a comment -

        Marc: Can you put that in the form of a patch for JFFI? Or did you do that already?

        Show
        Charles Oliver Nutter added a comment - Marc: Can you put that in the form of a patch for JFFI? Or did you do that already?
        Hide
        Charles Oliver Nutter added a comment -

        This appears to be fixed with a proper JNI_OnUnload + pthread_key_delete call on jffi master, so I'm optimistically marking this resolves in RC1.

        Show
        Charles Oliver Nutter added a comment - This appears to be fixed with a proper JNI_OnUnload + pthread_key_delete call on jffi master, so I'm optimistically marking this resolves in RC1.

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Dax
          • Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: