Patch: handle broken backtrace()
Jeff Sturm
jeff.sturm@appnet.com
Wed Jul 19 06:50:00 GMT 2000
The backtrace() function on some glibc platforms (Linux/Alpha) is
apparently unimplemented and always returns zero. This breaks
Throwable::fillInStackTrace, which always expect a return value
of at least one.
This patch fixes PR 286.
2000-07-19 Jeff Sturm <jeff.sturm@appnet.com>
* java/lang/natThrowable.cc (fillInStackTrace): Check for
zero return from backtrace().
Index: java/lang/natThrowable.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/lang/natThrowable.cc,v
retrieving revision 1.6
diff -u -p -r1.6 natThrowable.cc
--- natThrowable.cc 2000/06/23 19:53:33 1.6
+++ natThrowable.cc 2000/07/19 13:41:19
@@ -61,9 +61,12 @@ java::lang::Throwable::fillInStackTrace
int n = backtrace (p, 128) - 1;
#endif
- // ??? Might this cause a problem if the byte array isn't aligned?
- stackTrace = JvNewByteArray (n * sizeof p[0]);
- memcpy (elements (stackTrace), p+1, (n * sizeof p[0]));
+ if (n > 0)
+ {
+ // ??? Might this cause a problem if the byte array isn't aligned?
+ stackTrace = JvNewByteArray (n * sizeof p[0]);
+ memcpy (elements (stackTrace), p+1, (n * sizeof p[0]));
+ }
#endif
More information about the Java-patches
mailing list