[MacRuby-devel] [MacRuby] #412: Calling return from a Proc raises an exception (was: Calling return in a block raises an exception)

MacRuby ruby-noreply at macosforge.org
Fri Oct 30 12:14:34 PDT 2009


#412: Calling return from a Proc raises an exception
-------------------------------+--------------------------------------------
 Reporter:  mike@…             |       Owner:  lsansonetti@…        
     Type:  defect             |      Status:  new                  
 Priority:  blocker            |   Milestone:                       
Component:  MacRuby            |    Keywords:                       
-------------------------------+--------------------------------------------

Comment(by lsansonetti@…):

 Looks like #call is dispatched outside the return-from-block handler.

 {{{
 $ gdb --args ./miniruby -e "proc { return 42 }.call"
 GNU gdb 6.3.50-20050815 (Apple version gdb-1344) (Fri Jul  3 01:19:56 UTC
 2009)
 Copyright 2004 Free Software Foundation, Inc.
 GDB is free software, covered by the GNU General Public License, and you
 are
 welcome to change it and/or distribute copies of it under certain
 conditions.
 Type "show copying" to see the conditions.
 There is absolutely no warranty for GDB.  Type "show warranty" for
 details.
 This GDB was configured as "x86_64-apple-darwin"...Reading symbols for
 shared libraries ......... done

 (gdb) r
 Starting program: /Users/lrz/src/macruby-trunk/miniruby -e proc\ \{\
 return\ 42\ \}.call
 Reading symbols for shared libraries .++++++++.................... done
 uncaught Objective-C/C++ exception...
 terminate called after throwing an instance of
 'RoxorReturnFromBlockException*'

 Program received signal SIGABRT, Aborted.
 0x00007fff80158096 in __kill ()
 (gdb) p RoxorCompiler::module->dump()
 ; ModuleID = 'Roxor'
 target triple = "x86_64-apple-darwin"

 define i64 @__ruby_scope(i64 %self, i8* %sel) {
 MainBlock:
   %0 = tail call i8* (i8*, i32, i64, i64, i8**, i8*, i32, ...)*
 @rb_vm_prepare_block(i8* inttoptr (i64 4311691648 to i8*), i32 0, i64
 %self, i64 0, i8** null, i8* null, i32 0, i32 0) ; <i8*> [#uses=1]
   %1 = invoke i64 (i8*, i64, i64, i8*, i8*, i8, i32, ...)*
 @rb_vm_dispatch(i8* inttoptr (i64 4311694496 to i8*), i64 %self, i64
 %self, i8* inttoptr (i64 4311539472 to i8*), i8* %0, i8 2, i32 0)
           to label %normal unwind label %return-from-block ; <i64>
 [#uses=1]

 return-from-block:                                ; preds = %MainBlock
   %2 = tail call i8* @llvm.eh.exception()         ; <i8*> [#uses=2]
   %3 = tail call i64 (i8*, i8*, ...)* @llvm.eh.selector.i64(i8* %2, i8*
 bitcast (i8* ()* @__gxx_personality_v0 to i8*), i8* null) ; <i64>
 [#uses=0]
   %4 = tail call i8* @__cxa_begin_catch(i8* %2)   ; <i8*> [#uses=1]
   %5 = tail call i64 @rb_vm_check_return_from_block_exc(i8* %4, i32 0) ;
 <i64> [#uses=2]
   %6 = icmp eq i64 %5, 6                          ; <i1> [#uses=1]
   br i1 %6, label %rethrow, label %ret

 normal:                                           ; preds = %MainBlock
   %7 = tail call i64 (i8*, i64, i64, i8*, i8*, i8, i32, ...)*
 @rb_vm_dispatch(i8* inttoptr (i64 4311690384 to i8*), i64 %self, i64 %1,
 i8* inttoptr (i64 140735458816510 to i8*), i8* null, i8 0, i32 0) ; <i64>
 [#uses=1]
   ret i64 %7

 ret:                                              ; preds = %return-from-
 block
   tail call void @__cxa_end_catch()
   ret i64 %5

 rethrow:                                          ; preds = %return-from-
 block
   tail call void @__cxa_rethrow()
   unreachable
 }

 define i64 @__ruby_scope1(i64 %self, i8* %sel, i64** %dvars, i8*
 %running_block) {
 MainBlock:
   tail call void @rb_vm_return_from_block(i64 169, i32 0)
   ret i64 169
 }

 declare void @rb_vm_return_from_block(i64, i32)

 declare i8* @rb_vm_prepare_block(i8*, i32, i64, i64, i8**, i8*, i32, ...)

 declare i64 @rb_vm_dispatch(i8*, i64, i64, i8*, i8*, i8, i32, ...)

 declare i8* @llvm.eh.exception() nounwind

 declare i64 @llvm.eh.selector.i64(i8*, i8*, ...) nounwind

 declare i8* @__gxx_personality_v0()

 declare i8* @__cxa_begin_catch(i8*)

 declare i64 @rb_vm_check_return_from_block_exc(i8*, i32)

 declare void @__cxa_end_catch()

 declare void @__cxa_rethrow()
 $1 = void
 }}}

 Note that this is a problem with Proc#call. Calling return from a non-Proc
 block should work. I altered the title.

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/412#comment:2>
MacRuby <http://macruby.org/>



More information about the MacRuby-devel mailing list