[MacRuby-devel] Assertion failed in rb_vm_super_lookup

Laurent Sansonetti lsansonetti at apple.com
Fri Nov 27 12:17:24 PST 2009


Hi Gareth,

On Nov 26, 2009, at 3:51 PM, Gareth Townsend wrote:

> Hi,
>
> I've just started playing with MacRuby. So please bear with me,  
> there's every chance I'm doing something stupid :-) I'm using 0.5  
> beta 2.
>
> I'm building a simple Cocoa App (http://github.com/quamen/noise) and  
> am running into some problems while trying to set up a Preference  
> Pane.
>
> Specifically this error:
>
>> Assertion failed: (m != NULL), function rb_vm_super_lookup, file  
>> dispatcher.cpp, line 228.

Sorry about that, this shouldn't happen. I will try to reduce this and  
add it to our test suite.

> Followed by a whole heap of warnings that seem to hard coded to  
> Laurent's machine
>
> Program received signal:  “SIGABRT”.
>> sharedlibrary apply-load-rules all
>> warning: Could not find object file "/Users/lrz/src/macruby-clean/ 
>> array.o" - no debug information available for "array.c".
>>
>> warning: Could not find object file "/Users/lrz/src/macruby-clean/ 
>> bignum.o" - no debug information available for "bignum.c".
>>
>> ...
>
>
> This occurs when I try to instantiate an NSWindowController  
> subclass. My Code:
>
>> def open_preferences(sender)
>> 	NSLog('open preferences')
>> 	preference_controller ||= PreferencesController.new
>> 	preference_controller.showWindow(self)
>> end
>
>> class PreferencesController < NSWindowController
>> 	def init
>> 		if (super initWithWindowNibName('preferences'))
>> 			self
>> 		else
>> 			nil
>> 		end
>> 	end
>> 	
>> end
>
>
> I have a .xib file called 'preferences.xib'
>
> So can anyone spot something stupid? If not, how should I go about  
> debugging this?

I guess you tried to translate [super  
initWithWindowNibName:@"preferences"] here. The problem is that super  
in Ruby doesn't work exactly the same as in Objective-C. super in  
Objective-C allows you to call any super method while in Ruby it will  
always call the super version of the caller (here, init).

In your PreferencesController class, unless you overwrote  
initWithWindowNibName:, you can simply call it without super.

class PreferencesController
   def init
     initWithWindowNibName('preferences')
   end
end

As John wrote earlier, init should always return self (or nil if there  
was an error). Here, initWithWindowNibName: is supposed to return self  
or nil in case of an error, so we can simply return its return value.

Laurent


More information about the MacRuby-devel mailing list