Posted by
Toon Verwaest-2 on
Mar 21, 2011; 9:57am
URL: https://forum.world.st/test-crashing-the-cog-vm-tp3393032p3393191.html
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: