Login  Register

Re: test crashing the cog vm

Posted by Toon Verwaest-2 on Mar 21, 2011; 10:53am
URL: https://forum.world.st/test-crashing-the-cog-vm-tp3393032p3393270.html

If this is all you are doing then yes, that is correct. If you expect
the format to be different in the new subclass you will have to
recalculate it, but since you aren't doing that in this example, this is
fine.

cheers,
Toon

On 03/21/2011 11:29 AM, Tudor Girba wrote:

> Thanks, Toon!
>
> I changed the code to explicitly set the format, and it seems to fix the problem:
>
> cls := Class new superclass: MooseElement;
> setFormat: MooseElement format;
> yourself.
> cls compileSilently: 'mooseName   ^ 1/0'.
> element := cls new.
>
> Is this correct?
>
> Cheers,
> Doru
>
>
> On 21 Mar 2011, at 10:57, Toon Verwaest wrote:
>
>> This does crash whenever you subclass a class which has instance variables and you try to access those instance variables. The problem is that you don't properly initialize your class, leaving you with a Class that has a wrong format. For example:
>>
>> cls := Class new superclass: Class; yourself.
>> cls format
>>
>> returns 2. 2 basically means it's an object with pointers but with 0 instance variables. If you instantiate the 'cls' I just made it also crashes. Why? Well, class has an initialize method that is compiled to write to the fields of the new instance. It puts an empty method dictionary into the class you create as an instance of my cls. This segfaults because you are writing outside of memory.
>>
>> So just make sure you properly create classes, with a proper format!
>>
>> This test should crash all VMs btw... at least at some point. Since you are writing in random memory it might take longer to notice it in some cases; especially when padded memory is owned by the garbage collector :)
>>
>> cheers,
>> Toon
>>
>> On 03/21/2011 10:24 AM, Tudor Girba wrote:
>>> Hi,
>>>
>>> Alex recently wrote a test in Moose that seems to crash the Cog VM at least on Mac.
>>>
>>> How to reproduce:
>>>
>>> - download the following image
>>> http://dl.dropbox.com/u/18323746/Tmp/moose-crashing-cog-jit.zip
>>>
>>> - execute the following code in the workspace (already provided in the image)
>>> cls := Class new superclass: MooseElement; yourself.
>>> cls compileSilently: 'mooseName   ^ 1/0'.
>>> element := cls new.
>>>
>>> - I used all of the followings and they all crashed:
>>> https://pharo-ic.lille.inria.fr/hudson/view/Cog/job/Cog%20Mac%20Cocoa/4/artifact/cog/build/Cog.zip
>>> https://pharo-ic.lille.inria.fr/hudson/view/Cog/job/StackVM%20Mac%20Cocoa/2/artifact/cog/build/StackVM.zip
>>> http://www.mirandabanda.org/files/Cog/VM/VM.r2370/Cog.app.tgz
>>> http://www.mirandabanda.org/files/Cog/VM/VM.r2361/Cog.app.tgz
>>>
>>>
>>> The strange thing is that the crash only happens when we subclass MooseElement, but not another class.
>>>
>>> Could someone take a look?
>>>
>>> Cheers,
>>> Doru
>>>
>>>
>>> --
>>> www.tudorgirba.com
>>>
>>> "Every thing should have the right to be different."
>>>
>>>
>>>
>>>
>>
> --
> www.tudorgirba.com
>
> "Every thing has its own flow."
>
>
>
>
>