Hi Nicolas, List,
I'm using Ubuntu 6.10 on x86 and the latest CVS Neko compiled with the
version of GCC that comes with Ubuntu, which I have just discovered to
my horror to be a prerelease of 4.1.2. Running almost any Neko binary
causes neko -interp to crash with a segfault:
The problem is in line 563 of vm/interp.c, where acc is clobbered by
otable_find. I was at a loss as to how this was happening until I
realised that acc is being stored in %eax. My understanding of the
docs is that GCC should be smart enough to know when it's necessary to
save and restore a register variable and do so automatically, but
that's not happening in this case for whatever reason. I did try
unsetting COMPACT_TABLE to use the other versions of the otable
functions, but the problem remained all the same.
I'm not sure whether this is a "real" problem, or just a compiler bug,
but I solved the problem to my satisfaction by just ACC_BACKUP and
ACC_RESTOREing around the problem function call. Patch enclosed.
Thanks,
Dan.
Index: vm/interp.c
===================================================================
RCS file: /cvsroot/neko/vm/interp.c,v
retrieving revision 1.83
diff -u -r1.83 interp.c
--- vm/interp.c 20 Apr 2007 14:05:48 -0000 1.83
+++ vm/interp.c 22 Apr 2007 02:43:11 -0000
@@ -560,7 +560,9 @@
value *f;
value old = (value)acc;
do {
+ ACC_BACKUP;
f = otable_find(((vobject*)acc)->table,(field)*pc);
+ ACC_RESTORE;
if( f )
break;
acc = (int_val)((vobject*)acc)->proto;
--
Neko : One VM to run them all
(http://nekovm.org)