bugs in stackTrace.c

Stefan Burstroem kaffe@rufus.w3.org
Sat, 22 Aug 1998 03:56:06 +0200 (MET DST)


Hi!
While I was trying to get Kaffe compile and run on my Amiga I ran accros a little bug
in the stackTrace code. When a builtin C function adds itself to the stackframes,
it adds itself with a methodptr = 1. When the printStackFrame tries to print the code,
it accesses illegal addresses since it tries to access a method block at address 1.
I guess that this would cause a core dump on Unix, but I havn't been able to confirm this.
Anyone else?
An easy way to reproduce it is to run 'Kaffe NonExistingClassName' to make it throw an
ClassNotExistsException.
Anyway, applying this patch should fix this problem.

regards,
Stefan Burstroem
stefan@omnipresence.com


*** kaffe/kaffevm/stackTrace.c Sat Apr 04 23:19:07 1998
--- source:kaffe-1.0.b1.snap_jit_sb980818/kaffe/kaffevm/stackTrace.c Sat Aug 22 03:37:38 1998
***************
*** 188,193 ****
--- 188,194 ----
    meth = findMethodFromPC(pc);
  #endif
    if (meth != 0) {
+    if(meth != (void *)1) {
      linepc = 0;
      linenr = -1;
      if (meth->lines != 0) {
***************
*** 208,213 ****
--- 209,217 ----
        CLASS_CNAME(meth->class),
        meth->name->data,
        linenr);
+     }
+    } else { /* The method is really a compiled C function */
+     sprintf(buf, "\tat (compiled C code)");
     }
     len = strlen(buf);
     str = newArray(TYPE_CLASS(TYPE_Char), len);