Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.7.0.pre1
    • Fix Version/s: JRuby 1.7.0.pre2
    • Component/s: Core Classes/Modules
    • Labels:
      None
    • Environment:
      in --1.8 mode!
      rails 3.2.2
      jruby 1.7.0.preview1 (ruby-1.9.3-p203) (2012-06-05 09e1090f) (Java HotSpot(TM) 64-Bit Server VM 1.7.0_04) [darwin-x86_64-java]
    • Number of attachments :
      0

      Description

      In some situations, when having errors/exceptions in ERB templates, JRuby crashes with a nullpointer exception. Unfortunately I wasn't able to reproduce this error in a simpler context. I hope the stracktrace is enough to track down this error. The NullpointerException does not happen with 1.6.4. I think it is related to the use of --1.8 mode.

      Following stacktrace is made with JRuby commit ID 09e1090fbc404a579e52431e05f1ee2a32db2ff1.

       
      RaiseException.java:101:in `<init>': java.lang.NullPointerException
      	from Ruby.java:3551:in `newRaiseException'
      	from Ruby.java:3526:in `newEncodingCompatibilityError'
      	from RubyString.java:1366:in `cat'
      	from RubyString.java:1298:in `cat19'
      	from RubyArray.java:1487:in `inspectAry'
      	from RubyArray.java:1508:in `inspect'
      	from RubyArray$INVOKER$i$0$0$inspect.gen:-1:in `call'
      	from RubyClass.java:679:in `finvoke'
      	from RuntimeHelpers.java:541:in `invoke'
      	from RubyBasicObject.java:364:in `callMethod'
      	from RubyObject.java:394:in `inspect'
      	from RubyArray.java:1482:in `inspectAry'
      	from RubyArray.java:1508:in `inspect'
      	from RubyArray$INVOKER$i$0$0$inspect.gen:-1:in `call'
      	from RubyClass.java:679:in `finvoke'
      	from RuntimeHelpers.java:541:in `invoke'
      	from RubyBasicObject.java:364:in `callMethod'
      	from RubyBasicObject.java:1121:in `inspectObj'
      	from RubyBasicObject.java:1089:in `hashyInspect'
      	from RubyBasicObject.java:1068:in `inspect'
      	from RubyKernel.java:1854:in `inspect'
      	from RubyKernel$INVOKER$s$0$0$inspect.gen:-1:in `call'
      	from RubyClass.java:679:in `finvoke'
      	from RuntimeHelpers.java:541:in `invoke'
      	from RubyBasicObject.java:364:in `callMethod'
      	from RubyObject.java:394:in `inspect'
      	from RubyHash.java:727:in `visit'
      	from RubyHash.java:594:in `visitAll'
      	from RubyHash.java:722:in `inspectHash'
      	from RubyHash.java:756:in `inspect'
      	from RubyHash$INVOKER$i$0$0$inspect.gen:-1:in `call'
      	from RubyClass.java:679:in `finvoke'
      	from RuntimeHelpers.java:541:in `invoke'
      	from RubyBasicObject.java:364:in `callMethod'
      	from RubyBasicObject.java:1121:in `inspectObj'
      	from RubyBasicObject.java:1089:in `hashyInspect'
      	from RubyBasicObject.java:1068:in `inspect'
      	from RubyKernel.java:1854:in `inspect'
      	from RubyKernel$INVOKER$s$0$0$inspect.gen:-1:in `call'
      	from RubyClass.java:679:in `finvoke'
      	from RuntimeHelpers.java:541:in `invoke'
      	from RubyBasicObject.java:364:in `callMethod'
      	from RubyObject.java:394:in `inspect'
      	from RubyNameError.java:120:in `to_str'
      	from RubyNameError$RubyNameErrorMessage$INVOKER$i$0$0$to_str.gen:-1:in `call'
      	from RubyClass.java:679:in `finvoke'
      	from RuntimeHelpers.java:541:in `invoke'
      	from RubyBasicObject.java:364:in `callMethod'
      	from TypeConverter.java:71:in `convertToType'
      	from TypeConverter.java:117:in `convertToType'
      	from RubyBasicObject.java:758:in `convertToString'
      	from RubyNameError.java:202:in `to_s'
      	from RubyNameError$INVOKER$i$0$0$to_s.gen:-1:in `call'
      	from RubyClass.java:679:in `finvoke'
      	from RuntimeHelpers.java:541:in `invoke'
      	from RubyBasicObject.java:364:in `callMethod'
      	from RubyException.java:266:in `message'
      	from RaiseException.java:181:in `getMessage'
      	from Throwable.java:391:in `getLocalizedMessage'
      	from Throwable.java:479:in `toString'
      	from Throwable.java:311:in `<init>'
      	from Exception.java:102:in `<init>'
      	from ExecutionException.java:92:in `<init>'
      	from FutureTask.java:252:in `innerGet'
      	from FutureTask.java:111:in `get'
      	from NativeMethodAccessorImpl.java:-2:in `invoke0'
      	from NativeMethodAccessorImpl.java:57:in `invoke'
      	from DelegatingMethodAccessorImpl.java:43:in `invoke'
      	from Method.java:601:in `invoke'
      	from JavaMethod.java:440:in `invokeDirectWithExceptionHandling'
      	from JavaMethod.java:304:in `invokeDirect'
      	from InstanceMethodInvoker.java:50:in `call'
      	from MethodHandle.java:566:in `invokeWithArguments'
      	from InvocationLinker.java:149:in `invocationFallback'
      	from lib/payout_printer.rb:159:in `block_8$RUBY$__file__'
      	from lib$payout_printer$block_8$RUBY$__file__:-1:in `call'
      	from CompiledBlock.java:112:in `yield'
      	from CompiledBlock.java:95:in `yield'
      	from Block.java:130:in `yield'
      	from RubyArray.java:1604:in `eachCommon'
      	from RubyArray.java:1611:in `each'
      	from MethodHandleImpl.java:1146:in `invoke_L4'
      	from MethodHandleImpl.java:1146:in `invoke_L4'
      	from MethodHandle.java:566:in `invokeWithArguments'
      	from InvocationLinker.java:241:in `invocationFallback'
      	from lib/payout_printer.rb:156:in `block_3$RUBY$__file__'
      	from lib$payout_printer$block_3$RUBY$__file__:-1:in `call'
      	from CompiledBlock.java:112:in `yield'
      	from CompiledBlock.java:95:in `yield'
      	from Block.java:130:in `yield'
      	from YieldNode.java:119:in `interpret'
      	from NewlineNode.java:104:in `interpret'
      	from BlockNode.java:71:in `interpret'
      	from EnsureNode.java:96:in `interpret'
      	from ASTInterpreter.java:75:in `INTERPRET_METHOD'
      	from InterpretedMethod.java:169:in `call'
      	from DefaultMethod.java:191:in `call'
      	from MethodHandleImpl.java:1146:in `invoke_L4'
      	from MethodHandleImpl.java:1146:in `invoke_L4'
      	from MethodHandle.java:566:in `invokeWithArguments'
      	from InvocationLinker.java:241:in `invocationFallback'
      	from lib/payout_printer.rb:91:in `__file__'
      	from lib/payout_printer.rb:-1:in `load'
      	from Ruby.java:778:in `runScript'
      	from Ruby.java:771:in `runScript'
      	from Ruby.java:648:in `runNormally'
      	from Ruby.java:497:in `runFromMain'
      	from Main.java:376:in `doRunFromMain'
      	from Main.java:265:in `internalRun'
      	from Main.java:231:in `run'
      	from Main.java:215:in `run'
      	from Main.java:195:in `main'
      

        Activity

        Hide
        Ben Browning added a comment -

        I remember helping someone else track this down a while back but looks like we forgot to make a JIRA for it. The initExceptions method of Ruby.java - https://github.com/jruby/jruby/blob/master/src/org/jruby/Ruby.java#L1476 - only initializes the encoding CompatibilityError when running in 1.9 mode but as you've discovered there are some code paths in 1.8 mode that will try to raise this error. Those code paths either need to raise a different error or the CompatibilityError needs to be initialized for both 1.8 and 1.9 modes.

        Show
        Ben Browning added a comment - I remember helping someone else track this down a while back but looks like we forgot to make a JIRA for it. The initExceptions method of Ruby.java - https://github.com/jruby/jruby/blob/master/src/org/jruby/Ruby.java#L1476 - only initializes the encoding CompatibilityError when running in 1.9 mode but as you've discovered there are some code paths in 1.8 mode that will try to raise this error. Those code paths either need to raise a different error or the CompatibilityError needs to be initialized for both 1.8 and 1.9 modes.
        Hide
        Reto Schüttel added a comment -

        Heya Ben. That was me. I tried to reapproach that problem again some time later, but wasn't able to reproduce it again. Today it happened again and I decided to open a ticket right away. Thanks very much for remembering (and for looking into it last, and this time)!

        After I reported this bug today, I also noticed that the error doesn't happen if the call doesn't happen via a Java callback. I wasn't aware of that important detail .

        To make it more clear: The ruby code, that triggers the error, gets started as a Callable from Java.

        1. Ruby main
        2. Start Executeable Queue
        3. Create Worker Object
        4. Wrap Worker Object in FutureTask
        5. push it onto the queue
        6. wait for the execution
        6. get the result via FutureTask#get

        I hope this helps!

        Show
        Reto Schüttel added a comment - Heya Ben. That was me. I tried to reapproach that problem again some time later, but wasn't able to reproduce it again. Today it happened again and I decided to open a ticket right away. Thanks very much for remembering (and for looking into it last, and this time)! After I reported this bug today, I also noticed that the error doesn't happen if the call doesn't happen via a Java callback. I wasn't aware of that important detail . To make it more clear: The ruby code, that triggers the error, gets started as a Callable from Java. 1. Ruby main 2. Start Executeable Queue 3. Create Worker Object 4. Wrap Worker Object in FutureTask 5. push it onto the queue 6. wait for the execution 6. get the result via FutureTask#get I hope this helps!
        Hide
        Reto Schüttel added a comment -

        some more observations after discussing this issue with enebo and bbrowning:

        • Error happens when concating two strings with different encodings using RubyString#cat19. This for example happens with Array Inspect in Ruby 1.8 mode
        • In Ruby 1.8 Mode, all strings should be declared to have the same encoding, apparently this is not the case in my project
        Show
        Reto Schüttel added a comment - some more observations after discussing this issue with enebo and bbrowning: Error happens when concating two strings with different encodings using RubyString#cat19. This for example happens with Array Inspect in Ruby 1.8 mode In Ruby 1.8 Mode, all strings should be declared to have the same encoding, apparently this is not the case in my project
        Hide
        Thomas E Enebo added a comment -

        Our assumption about cat19 working for 1.8 mode for aryInspect is wrong. In 1.8 if you have one element which is 8BIT and another USASCII then we will trigger an encoding exception error. Secondly, having to put a comment saying it is safe is probably more confusing than just using the version specific cats.

        Show
        Thomas E Enebo added a comment - Our assumption about cat19 working for 1.8 mode for aryInspect is wrong. In 1.8 if you have one element which is 8BIT and another USASCII then we will trigger an encoding exception error. Secondly, having to put a comment saying it is safe is probably more confusing than just using the version specific cats.

          People

          • Assignee:
            Thomas E Enebo
            Reporter:
            Reto Schüttel
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: