Project

General

Profile

Backport #5234

`unexpected return' occurs when a proc is called in ensure

Added by ko1 (Koichi Sasada) almost 8 years ago. Updated about 3 years ago.

Status:
Rejected
Priority:
Normal
[ruby-core:39125]

Description

Similar as Bug #2729, `unexpected return' occurs when a proc is called in ensure. I'm not sure why it doesn't fix with Bug #2729.

test code

class C
def each
begin
yield :foo
ensure
Proc.new
end
end

def detect
each{|e|
r = yield(e)
return true if r
}
false
end
end

p C.new.detect{|e|
true
}

Associated revisions

Revision a09e7139
Added by ktsj (Kazuki Tsujimoto) almost 8 years ago

  • proc.c (proc_new): force to rewrite errinfo when calling Proc.new in ensure.
    [Bug #5234] [ruby-core:39125]
    This code will be removed after changing throw mechanism (see r33064).

  • vm.c (rb_vm_rewrite_dfp_in_errinfo): new function.

  • vm.c (vm_make_env_each): changed accordingly.

  • vm_core.h: ditto.

  • bootstraptest/test_flow.rb: add tests for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 33096
Added by ktsj (Kazuki Tsujimoto) almost 8 years ago

  • proc.c (proc_new): force to rewrite errinfo when calling Proc.new in ensure.
    [Bug #5234] [ruby-core:39125]
    This code will be removed after changing throw mechanism (see r33064).

  • vm.c (rb_vm_rewrite_dfp_in_errinfo): new function.

  • vm.c (vm_make_env_each): changed accordingly.

  • vm_core.h: ditto.

  • bootstraptest/test_flow.rb: add tests for above.

Revision 33096
Added by ktsj (Kazuki Tsujimoto) almost 8 years ago

  • proc.c (proc_new): force to rewrite errinfo when calling Proc.new in ensure.
    [Bug #5234] [ruby-core:39125]
    This code will be removed after changing throw mechanism (see r33064).

  • vm.c (rb_vm_rewrite_dfp_in_errinfo): new function.

  • vm.c (vm_make_env_each): changed accordingly.

  • vm_core.h: ditto.

  • bootstraptest/test_flow.rb: add tests for above.

Revision 33096
Added by ktsj (Kazuki Tsujimoto) almost 8 years ago

  • proc.c (proc_new): force to rewrite errinfo when calling Proc.new in ensure.
    [Bug #5234] [ruby-core:39125]
    This code will be removed after changing throw mechanism (see r33064).

  • vm.c (rb_vm_rewrite_dfp_in_errinfo): new function.

  • vm.c (vm_make_env_each): changed accordingly.

  • vm_core.h: ditto.

  • bootstraptest/test_flow.rb: add tests for above.

Revision 33096
Added by ktsj (Kazuki Tsujimoto) almost 8 years ago

  • proc.c (proc_new): force to rewrite errinfo when calling Proc.new in ensure.
    [Bug #5234] [ruby-core:39125]
    This code will be removed after changing throw mechanism (see r33064).

  • vm.c (rb_vm_rewrite_dfp_in_errinfo): new function.

  • vm.c (vm_make_env_each): changed accordingly.

  • vm_core.h: ditto.

  • bootstraptest/test_flow.rb: add tests for above.

Revision 33096
Added by ktsj (Kazuki Tsujimoto) almost 8 years ago

  • proc.c (proc_new): force to rewrite errinfo when calling Proc.new in ensure.
    [Bug #5234] [ruby-core:39125]
    This code will be removed after changing throw mechanism (see r33064).

  • vm.c (rb_vm_rewrite_dfp_in_errinfo): new function.

  • vm.c (vm_make_env_each): changed accordingly.

  • vm_core.h: ditto.

  • bootstraptest/test_flow.rb: add tests for above.

Revision 33096
Added by ktsj (Kazuki Tsujimoto) almost 8 years ago

  • proc.c (proc_new): force to rewrite errinfo when calling Proc.new in ensure.
    [Bug #5234] [ruby-core:39125]
    This code will be removed after changing throw mechanism (see r33064).

  • vm.c (rb_vm_rewrite_dfp_in_errinfo): new function.

  • vm.c (vm_make_env_each): changed accordingly.

  • vm_core.h: ditto.

  • bootstraptest/test_flow.rb: add tests for above.

Revision 3bffb317
Added by ktsj (Kazuki Tsujimoto) almost 8 years ago

  • backport r33096 from trunk.

  • proc.c (proc_new): force to rewrite errinfo when calling Proc.new in ensure.
    [Bug #5234] [ruby-core:39125]

  • vm.c (rb_vm_rewrite_dfp_in_errinfo): new function.

  • vm.c (vm_make_env_each): changed accordingly.

  • vm_core.h: ditto.

  • bootstraptest/test_flow.rb: add tests for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@33098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

History

Updated by ktsj (Kazuki Tsujimoto) almost 8 years ago

The cause is Proc.new doesn't rewrite errinfo.

A following patch fixes this problem.
I'll commit it to trunk/ruby_1_9_3 later.

https://gist.github.com/1175062

#2

Updated by ktsj (Kazuki Tsujimoto) almost 8 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r33096.
Koichi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • proc.c (proc_new): force to rewrite errinfo when calling Proc.new in ensure.
    [Bug #5234] [ruby-core:39125]
    This code will be removed after changing throw mechanism (see r33064).

  • vm.c (rb_vm_rewrite_dfp_in_errinfo): new function.

  • vm.c (vm_make_env_each): changed accordingly.

  • vm_core.h: ditto.

  • bootstraptest/test_flow.rb: add tests for above.

Updated by andhapp (Anuj Dutta) almost 8 years ago

Same issue occurs on 1.9.2-p290. Can this be backported to it as well?

Thanks.

#4

Updated by ktsj (Kazuki Tsujimoto) almost 8 years ago

  • Tracker changed from Bug to Backport
  • Status changed from Closed to Assigned
  • Assignee changed from ko1 (Koichi Sasada) to yugui (Yuki Sonoda)

Yugui-san:

Could you consider backporting the fix?

Updated by ktsj (Kazuki Tsujimoto) almost 8 years ago

  • Target version changed from 1.9.3 to 1.9.2
#6

Updated by kosaki (Motohiro KOSAKI) almost 8 years ago

  • Project changed from Ruby master to Backport192
  • Category changed from core to core
  • Target version deleted (1.9.2)
#7

Updated by naruse (Yui NARUSE) about 3 years ago

  • Status changed from Assigned to Rejected

Also available in: Atom PDF