[MacRuby] #1447: Crash - Assertion failed in RoxorVM::pop_current_exception
#1447: Crash - Assertion failed in RoxorVM::pop_current_exception --------------------------------+------------------------------------------- Reporter: msabramo@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: crash, GCD --------------------------------+------------------------------------------- Using the extra debug logging that I mentioned in #1446, I took the app that I was working on that was crashing (http://urbancoding.github.com/jenx/) and reduced it down quite a bit. I will attach a tarball with the Xcode project (I attempted to reproduce the problem in a simple command-line RSpec, but I couldn't). When I run the attached tarball with a MacRuby with the change mentioned in #1446, I get this output: {{{ GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 15 16:03:10 UTC 2011) 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".Setting environment variable "MANPATH_WITHOUT_PERLBREW" to null value. Setting environment variable "SHMUX_SSH_OPTS" to null value. tty /dev/ttys004 [Switching to process 63033 thread 0x0] 2012-02-04 12:33:49.342 Jenx[63033:903] Could not find image named 'refresh'. 2012-02-04 12:33:49.344 Jenx[63033:903] Could not find image named 'projects'. 2012-02-04 12:33:49.348 Jenx[63033:903] Could not connect the action ensure_connection: to target of class Jenx 2012-02-04 12:33:49.348 Jenx[63033:903] Could not connect the action show_preferences_window: to target of class Jenx 2012-02-04 12:33:49.457 Jenx[63033:903] switch_to_module - mod = #<PreferencesGeneralViewController:0x2005be7a0> 2012-02-04 12:33:49.477 Jenx[63033:903] Could not connect the action save_preferences: to target of class PreferencesGeneralViewController 2012-02-04 12:33:49.478 Jenx[63033:903] PreferencesGeneralViewController.load_projects - Calling all_projects - url = "http://anunresolvablehostname.com/foobar"... 2012-02-04 12:33:49.489 Jenx[63033:903] Creating JenxConnectionManager... 2012-02-04 12:33:49.499 Jenx[63033:903] JenxConnectionManager.initialize calling async... 2012-02-04 12:33:49.501 Jenx[63033:903] JenxConnectionManager.initialize @value = nil 2012-02-04 12:33:49.506 Jenx[63033:903] .value waiting... *** Dispatch block exited prematurely because of an uncaught exception: /Users/marca/Library/Developer/Xcode/DerivedData/jenx- gcpqjcbitzazsievjxaddpxmrtnb/Build/Products/Debug/jenx.app/Contents/Resources/JenxConnection.rb:42:in `block': getaddrinfo: nodename nor servname provided, or not known (SocketError) from /Users/marca/Library/Developer/Xcode/DerivedData/jenx- gcpqjcbitzazsievjxaddpxmrtnb/Build/Products/Debug/jenx.app/Contents/Resources/JenxConnectionManager.rb:15:in `block' 2012-02-04 12:33:49.626 Jenx[63033:903] .value about to return @value = nil 2012-02-04 12:33:49.627 Jenx[63033:903] 1 - connection_result.value = 2012-02-04 12:33:49.628 Jenx[63033:903] .value waiting... 2012-02-04 12:33:49.628 Jenx[63033:903] .value about to return @value = nil 2012-02-04 12:33:49.629 Jenx[63033:903] .value waiting... 2012-02-04 12:33:49.630 Jenx[63033:903] .value about to return @value = nil 2012-02-04 12:33:49.630 Jenx[63033:903] 2 - connection_result.value = 2012-02-04 12:33:49.631 Jenx[63033:903] .value waiting... 2012-02-04 12:33:49.631 Jenx[63033:903] .value about to return @value = nil 2012-02-04 12:33:49.632 Jenx[63033:903] PreferencesGeneralViewController.load_projects - Called all_projects DONE. @all_projects = nil RoxorVM::pop_current_exception (vm.cpp:3607) - Warning: Assertion about to fail: ((size_t)pos < current_exceptions.size()); pos = 1; current_exceptions.size() = 1 current_exceptions[1]: "#<NoMethodError: undefined method `[]' for nil:NilClass>" Assertion failed: ((size_t)pos < current_exceptions.size()), function pop_current_exception, file vm.cpp, line 3616. sharedlibrary apply-load-rules all Current language: auto; currently objective-c }}} So most likely the crash is related to uncaught exceptions inside a Grand Central Dispatch (GCD) queue. -- Ticket URL: <http://www.macruby.org/trac/ticket/1447> MacRuby <http://macruby.org/>
#1447: Crash - Assertion failed in RoxorVM::pop_current_exception --------------------------------+------------------------------------------- Reporter: msabramo@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: crash, GCD --------------------------------+------------------------------------------- Comment(by msabramo@…): Just reduced this to a much, much smaller example (small enough to paste here!). I'm assuming the problem is raising an exception in a rescue: {{{ $ cat test4.spec framework 'Foundation' describe 'Stuff' do it 'should not crash' do begin nil[] rescue Exception => error NSLog(error) end end end $ macrspec -f d test4.spec Stuff Assertion failed: ((size_t)pos < current_exceptions.size()), function pop_current_exception, file vm.cpp, line 3596. Abort trap }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1447#comment:2> MacRuby <http://macruby.org/>
#1447: Crash - Assertion failed in RoxorVM::pop_current_exception --------------------------------+------------------------------------------- Reporter: msabramo@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: crash, GCD --------------------------------+------------------------------------------- Comment(by msabramo@…): In constrast, if I change `error` to `error.inspect`, then it's okay: {{{ $ cat test4.spec framework 'Foundation' describe 'Stuff' do it 'should not crash' do begin nil[] rescue Exception => error NSLog(error.inspect) end end end $ macrspec -f d test4.spec Stuff 2012-02-05 07:44:27.056 macruby[69053:903] #<NoMethodError: undefined method `[]' for nil:NilClass> should not crash Finished in 0.27099 seconds 1 example, 0 failures }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1447#comment:3> MacRuby <http://macruby.org/>
#1447: Crash - Assertion failed in RoxorVM::pop_current_exception --------------------------------+------------------------------------------- Reporter: msabramo@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: crash, GCD --------------------------------+------------------------------------------- Comment(by msabramo@…): Here it is in plain Ruby (no RSpec) and a little bit more debugging information (courtesy of my `vm.cpp` changes in #1446): {{{ $ cat test4.rb framework 'Foundation' begin nil[] rescue Exception => error NSLog(error) end $ macruby test4.rb RoxorVM::pop_current_exception (vm.cpp:3607) - Warning: Assertion about to fail: ((size_t)pos < current_exceptions.size()); pos = 1; current_exceptions.size() = 1 current_exceptions[1]: "#<NoMethodError: undefined method `[]' for nil:NilClass>" Assertion failed: ((size_t)pos < current_exceptions.size()), function pop_current_exception, file vm.cpp, line 3616. Abort trap }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1447#comment:4> MacRuby <http://macruby.org/>
#1447: Crash - Assertion failed in RoxorVM::pop_current_exception --------------------------------+------------------------------------------- Reporter: msabramo@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: crash, GCD --------------------------------+------------------------------------------- Comment(by msabramo@…): Here's the output with `ROXOR_VM_DEBUG` and `ROXOR_VM_DEBUG_CONST` #defined: {{{ $ ~/dev/git-repos/MacRuby/macruby test4.rb ... resolving -[NilClass []] resolving -[NilClass []] resolving -[NilClass []:] resolving -[NoMethodError to_str] vm.cpp:1303:rb_vm_const_lookup_level:outer(NSObject) path(Exception) lexical(true) defined(false) outer_stack(0x0) rb_vm_const_lookup_level:1307:vm->get_outer_stack outer_stack() rb_vm_const_lookup_level:1310:vm->get_current_outer outer_stack() resolving -[TopLevel NSLog:] resolving -[TopLevel NSLog:] resolving -[TopLevel NSLog:] gen Ruby -> C stub with types v@ resolving -[NoMethodError length] resolving -[NoMethodError length] RoxorVM::pop_current_exception (vm.cpp:3607) - Warning: Assertion about to fail: ((size_t)pos < current_exceptions.size()); pos = 1; current_exceptions.size() = 1 current_exceptions[1]: "#<NoMethodError: undefined method `[]' for nil:NilClass>" Assertion failed: ((size_t)pos < current_exceptions.size()), function pop_current_exception, file vm.cpp, line 3616. Abort trap }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1447#comment:5> MacRuby <http://macruby.org/>
#1447: Crash - Assertion failed in RoxorVM::pop_current_exception --------------------------------+------------------------------------------- Reporter: msabramo@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: crash, GCD --------------------------------+------------------------------------------- Comment(by mrada@…): NSLog expects a string; by passing it an Exception object it raises the nested exception, and also explains why passing `error.inspect` fixes the issue. Another detail to note is that the nested exception is an Objective-C exception (NSInvalidArgumentException). I believe this type of issue has already been logged, and the solution to wrap some try/catch blocks around where the Objective-C method is called so the exception can be re-raised as a Ruby exception. I think also that Eloy's exception patch might fix this (https://github.com/MacRuby/MacRuby/pull/25), but I haven't tried yet. -- Ticket URL: <http://www.macruby.org/trac/ticket/1447#comment:6> MacRuby <http://macruby.org/>
#1447: Crash - Assertion failed in RoxorVM::pop_current_exception --------------------------------+------------------------------------------- Reporter: msabramo@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: crash, GCD --------------------------------+------------------------------------------- Comment(by mrada@…): Also, a further reduction that also causes MacRuby to crash, but not with the assertion failure: {{{ framework 'Foundation' NSLog(3) }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1447#comment:7> MacRuby <http://macruby.org/>
#1447: Crash - Assertion failed in RoxorVM::pop_current_exception --------------------------------+------------------------------------------- Reporter: msabramo@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: crash, GCD --------------------------------+------------------------------------------- Comment(by mrada@…): Ok, so the patch from Eloy doesn't fix this issue. Darn... -- Ticket URL: <http://www.macruby.org/trac/ticket/1447#comment:8> MacRuby <http://macruby.org/>
#1447: Crash - Assertion failed in RoxorVM::pop_current_exception --------------------------------+------------------------------------------- Reporter: msabramo@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: crash, GCD --------------------------------+------------------------------------------- Comment(by msabramo@…): Using added debug info in https://github.com/msabramo/MacRuby/commit/7a8f0cdb33584cfcf13281327900de945..., here's the output: {{{ $ DYLD_LIBRARY_PATH=~/dev/git-repos/MacRuby ~/dev/git- repos/MacRuby/macruby test4.rb ... resolving -[NilClass []] resolving -[NilClass []] resolving -[NilClass []:] resolving -[NoMethodError to_str] rb_vm_raise (vm.cpp:3684): exception = "#<NoMethodError: undefined method `[]' for nil:NilClass>" push_current_exception (vm.cpp:3598): exc = "#<NoMethodError: undefined method `[]' for nil:NilClass>" __vm_raise (vm.cpp:3568): rb_exc = "#<NoMethodError: undefined method `[]' for nil:NilClass>" rb_vm_is_eh_active (vm.cpp:3937): current_exception = "#<NoMethodError: undefined method `[]' for nil:NilClass>" resolving -[TopLevel NSLog:] resolving -[TopLevel NSLog:] resolving -[TopLevel NSLog:] gen Ruby -> C stub with types v@ resolving -[NoMethodError length] resolving -[NoMethodError length] rb_vm_pop_exception (vm.cpp:3976): Calling pop_current_exception(1)... RoxorVM::pop_current_exception (vm.cpp:3618) - Warning: Assertion about to fail: ((size_t)pos < current_exceptions.size()); pos = 1; current_exceptions.size() = 1 current_exceptions[0] = (0x20025fd40) "#<NoMethodError: undefined method `[]' for nil:NilClass>" Assertion failed: ((size_t)pos < current_exceptions.size()), function pop_current_exception, file vm.cpp, line 3622. Abort trap }}} The most suspect line, in my mind is compiler.cpp:4667: {{{ compile_pop_exception(1); }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1447#comment:9> MacRuby <http://macruby.org/>
#1447: Crash - Assertion failed in RoxorVM::pop_current_exception --------------------------------+------------------------------------------- Reporter: msabramo@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: crash, GCD --------------------------------+------------------------------------------- Comment(by mrada@…): Just to attempt to keep things organized, related tickets appear to be: #1422 and #1321, and probably a couple of others that have been buried quite deeply in trac at this point. -- Ticket URL: <http://www.macruby.org/trac/ticket/1447#comment:10> MacRuby <http://macruby.org/>
#1447: Crash - Assertion failed in RoxorVM::pop_current_exception --------------------------------+------------------------------------------- Reporter: msabramo@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: crash, GCD --------------------------------+------------------------------------------- Comment(by msabramo@…): Probably could remove the GCD keyword. -- Ticket URL: <http://www.macruby.org/trac/ticket/1447#comment:11> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby