Skip to content

crash while marking used variables #6456

@ahorek

Description

@ahorek

Environment Information
jruby 9.3.0.0-SNAPSHOT (2.6.5) 2020-11-06 f1d8b25 Java HotSpot(TM) 64-Bit Server VM 11.0.1+13-LTS on 11.0.1+13-LTS +jit [mswin32-x86_64]

Reproduction

require 'erb'
$VERBOSE = true

def call
  input = "<% x = [].each {}; data = '' %>"
  engine = ::ERB.new(input, trim_mode: '<>')
  data = engine.result(binding)
  data
end

call

related 397fd1c

Expected Behavior
the script shouldn't raise an exception

Actual Behavior

Unhandled Java exception: java.lang.NullPointerException
java.lang.NullPointerException: null
             markUsedVariable at org/jruby/parser/ScopedParserState.java:86
            addOrMarkVariable at org/jruby/parser/ParserSupport.java:213
  assignableLabelOrIdentifier at org/jruby/parser/ParserSupport.java:204
                      execute at org/jruby/parser/RubyParser.java:2405
                      yyparse at org/jruby/parser/RubyParser.java:1724
                      yyparse at org/jruby/parser/RubyParser.java:1597
                        parse at org/jruby/parser/RubyParser.java:5764
                        parse at org/jruby/parser/Parser.java:133
                        parse at org/jruby/parser/Parser.java:81
                    parseEval at org/jruby/Ruby.java:2618
                    prepareIC at org/jruby/ir/interpreter/Interpreter.java:193
                   evalCommon at org/jruby/ir/interpreter/Interpreter.java:150
              evalWithBinding at org/jruby/ir/interpreter/Interpreter.java:182
                   evalCommon at org/jruby/RubyKernel.java:1160
                         eval at org/jruby/RubyKernel.java:1122
                         call at org/jruby/RubyKernel$INVOKER$s$0$3$eval.gen:-1
                 cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:328
                         call at org/jruby/runtime/callsite/CachingCallSite.java:86
                    interpret at org/jruby/ir/instructions/CallBase.java:549
                  processCall at org/jruby/ir/interpreter/InterpreterEngine.java:361
                    interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:72
                    interpret at org/jruby/ir/interpreter/InterpreterEngine.java:86
             INTERPRET_METHOD at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:156
                         call at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:143
                         call at org/jruby/internal/runtime/methods/DynamicMethod.java:203
                 cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:371
                         call at org/jruby/runtime/callsite/CachingCallSite.java:174
          invokeOther3:result at erbi.rb:8
                         call at erbi.rb:8
                         call at org/jruby/internal/runtime/methods/CompiledIRMethod.java:185
                 cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:350
                         call at org/jruby/runtime/callsite/CachingCallSite.java:143
            invokeOther4:call at erbi.rb:12
                       <main> at erbi.rb:12
                          run at erbi.rb:-1
          invokeWithArguments at java/lang/invoke/MethodHandle.java:710
                         load at org/jruby/ir/Compiler.java:114
                    runScript at org/jruby/Ruby.java:1253
                  runNormally at org/jruby/Ruby.java:1172
                  runNormally at org/jruby/Ruby.java:1154
                  runNormally at org/jruby/Ruby.java:1190
                  runFromMain at org/jruby/Ruby.java:973
                doRunFromMain at org/jruby/Main.java:393
                  internalRun at org/jruby/Main.java:287
                          run at org/jruby/Main.java:234
                         main at org/jruby/Main.java:206

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions