bugs in stackTrace.c

Stefan Burstroem f94sbu at efd.lth.se
Thu Aug 27 06:00:49 PDT 1998


Hi again!

In article <199808271019.MAA29780 at kobra.efd.lth.se> you wrote:
>> 
>>  Hi Stefan,
>> 
>> I don't think it is possible for meth to ever become 1.
>> It either points to a valid method or is NULL.  Look at how
>> stackTrace.h finds the method.  For the translator, findMethodFromPC
>> won't return 1.  For the interpreter, TnextFrame in
>> systems/unix-jthread/internal.c maps the JNI frames with Method==1 to
>> NULL.
>> 
>> Can you construct an example where this failure occurs?
>> I did not understand your NonExistingClassName example.

>Start kaffe with a classname argument for a file that doesn't exist.
>Normally this should throw a ClassNotFoundException but instead I guess
>it will throw a Null pointer exception or core dump on unix since it tries
>to access address 5 (1+4) It did that here when I tried it 1 week ago and
>I found out that meth was equal to 1 when I traced the printStackFrame calls.
>It looks like there is something broken in some other place then since the
>(void *)1 was handled at some places, but apparently not on all places.
>I am not in front of my Amiga atm but I'll get back with more info (and 
>hopefully
>another patch) when I have some time to test it. (later this afternoon I
>guess)
>/Stefan

Sorry to say, but you were wrong :)

if the top stackframe contains a meth = (Method*)1 then Tnext is never
called. A possible patch would be to have STACKTRACEINIT() loop until it
has found a valid frame. Or another one would be to have buildStackTrace
look like this instead:

	STACKTRACEINIT(trace, base, base);
	cnt = 0;
	while(!STACKTRACEEND(trace)) {  /* <<<--- new code */
		if(STACKTRACEMETH(trace)!=-1)
			break;
		STACKTRACESTEP(trace);
	}

	while(!STACKTRACEEND(trace)) {
		STACKTRACESTEP(trace);
		cnt++;
	}				  /* <<<--- end new code */

	/* Build an array of stackTraceInfo */
	info = gc_malloc(sizeof(stackTraceInfo) * (cnt+1), GC_ALLOC_NOWALK);

	cnt = 0;

	STACKTRACEINIT(trace,base,base);
	while(!STACKTRACEEND(trace)) {	/* <<<--- new code */
		if(STACKTRACEMETH(trace)!=-1)
			break;
		STACKTRACESTEP(trace);
	}  				/* <<<--- new code */

	for(; !STACKTRACEEND(trace); STACKTRACESTEP(trace)) {
		info[cnt].pc = STACKTRACEPC(trace);
#if defined(INTERPRETER)
		info[cnt].meth = STACKTRACEMETH(trace);
#endif
#if defined(TRANSLATOR)
		info[cnt].meth = 0;	/* We do this lazily */
#endif
		cnt++;
	}



regards, Stefan Burstroem

-----------------------------------------------------------------------
>> Irl: Stefan Burstroem <<  >> Omnipresence Intl. <<  >> Irc: Yabba <<
 >> Phone: +46 (0)46-211 40 84 << >> EMail: stefan at omnipresence.com <<
-----------------------------------------------------------------------



More information about the kaffe mailing list