Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure clause is executed before begin clause ends ? #3174

Closed
yamam opened this issue Jul 24, 2015 · 1 comment
Closed

ensure clause is executed before begin clause ends ? #3174

yamam opened this issue Jul 24, 2015 · 1 comment

Comments

@yamam
Copy link

yamam commented Jul 24, 2015

The following script raises StackOverflowError.

var = true

proc1 = proc do
    if var
        begin
            var = false
            proc1.call
        ensure
            var = true
        end
    end
end

proc1.call
jruby 9.0.0.0 (2.2.2) 2015-07-21 e10ec96 Java HotSpot(TM) Client VM 25.51-b03 on 1.8.0_51-b16 +jit [Windows 7-x86]
io/console not supported; tty will not be manipulated
Error: Your application used more stack memory than the safety cap of 2048K.
Specify -J-Xss####k to increase it (#### = cap size in KB).
Exception trace follows:
java.lang.StackOverflowError
        at test.RUBY$block$\=test\,rb$0(test.rb:7)
        at org.jruby.runtime.CompiledIRBlockBody.commonYieldPath(CompiledIRBlockBody.java:70)
        at org.jruby.runtime.IRBlockBody.call(IRBlockBody.java:58)
        at org.jruby.runtime.Block.call(Block.java:106)
        at org.jruby.RubyProc.call(RubyProc.java:324)
        at org.jruby.RubyProc.call19(RubyProc.java:308)
        at org.jruby.RubyProc$INVOKER$i$0$0$call19.call(RubyProc$INVOKER$i$0$0$call19.gen)
        at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:197)
        at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:193)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:129)
        at test.invokeOther0:call(test.rb)
        at test.RUBY$block$\=test\,rb$0(test.rb:7)
        at org.jruby.runtime.CompiledIRBlockBody.commonYieldPath(CompiledIRBlockBody.java:70)
        at org.jruby.runtime.IRBlockBody.call(IRBlockBody.java:58)
        at org.jruby.runtime.Block.call(Block.java:106)
        ...
@enebo enebo added this to the JRuby 9.0.1.0 milestone Jul 24, 2015
@subbuss
Copy link
Contributor

subbuss commented Jul 27, 2015

This is a bug in LVA. It doesn't realize 'var' is still alive after the 'var = false' assignment which leads DCE to remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants