[MacRuby] #1422: MacRuby raises uncatchable exception when passed invalid argument with NSException

MacRuby ruby-noreply at macosforge.org
Fri Nov 18 20:14:31 PST 2011


#1422: MacRuby raises uncatchable exception when passed invalid argument with
NSException
----------------------------------+-----------------------------------------
 Reporter:  watson1978@…          |       Owner:  lsansonetti@…        
     Type:  defect                |      Status:  new                  
 Priority:  minor                 |   Milestone:                       
Component:  MacRuby               |    Keywords:                       
----------------------------------+-----------------------------------------
 Test Script:
 {{{
 #!ruby
 framework "Cocoa"

 begin
   str = NSMutableString.stringWithString("test")
   str.appendString(nil)
 rescue
   p :ok
 end

 begin
   exc = NSException.exceptionWithName("TestException",
                                       reason:"test", userInfo:nil)
   exc.raise
 rescue
   p :ok
 end

 # invalid argument
 begin
   begin
     exc = NSException.exceptionWithName("TestException",
                                         reason:42, userInfo:nil)
     exc.raise
   rescue
   end
 rescue
   p :ok
 end
 }}}

 Result:
 {{{
 $ macruby t.rb
 :ok
 :ok
 2011-11-19 13:04:19.281 macruby[53905:60b] -[__NSCFNumber UTF8String]:
 unrecognized selector sent to instance 0x2ac3
 uncaught Objective-C/C++ exception...
 2011-11-19 13:04:19.283 macruby[53905:60b] *** Terminating app due to
 uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber
 UTF8String]: unrecognized selector sent to instance 0x2ac3'
 *** First throw call stack:
 (
         0   CoreFoundation                      0x00007fff8e0e1286
 __exceptionPreprocess + 198
         1   libobjc.A.dylib                     0x00007fff8f600d5e
 objc_exception_throw + 43
         2   CoreFoundation                      0x00007fff8e16d4ce
 -[NSObject doesNotRecognizeSelector:] + 190
         3   CoreFoundation                      0x00007fff8e0ce133
 ___forwarding___ + 371
         4   CoreFoundation                      0x00007fff8e0cdf48
 _CF_forwarding_prep_0 + 232
         5   libmacruby.dylib                    0x00000001038264d8
 rb_oc2rb_exception + 120
         6   libmacruby.dylib                    0x00000001038725fb
 rb_vm_dispatch + 5883
         7   ???                                 0x0000000105326a44 0x0 +
 4382157380
         8   ???                                 0x0000000105326282 0x0 +
 4382155394
         9   libmacruby.dylib                    0x0000000103881c86
 rb_vm_run + 534
         10  libmacruby.dylib                    0x000000010378ef53
 ruby_run_node + 83
         11  macruby                             0x000000010375bd18 main +
 152
         12  macruby                             0x000000010375bc74 start +
 52
 )
 terminate called throwing an exceptionzsh: abort      macruby t.rb
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/1422>
MacRuby <http://macruby.org/>



More information about the macruby-tickets mailing list