This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: FYI: Fix PR 26990
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 04 Apr 2006 16:57:16 -0600
- Subject: Patch: FYI: Fix PR 26990
- Reply-to: tromey at redhat dot com
I'm checking this in on the trunk and the 4.1 branch.
This fixes PR 26990 by bypassing the security manager check during a
normal exit. It is written in a somewhat unusual way because I did
not want to break binary compatibility for 4.1.x.
Tom
2006-04-04 Tom Tromey <tromey@redhat.com>
PR libgcj/26990:
* prims.cc (_Jv_RunMain): Use exitNoChecksAccessor.
* gnu/java/lang/natMainThread.cc (call_main): Use
exitNoChecksAccessor.
* testsuite/libjava.lang/pr26990.out: New file.
* testsuite/libjava.lang/pr26990.java: New file.
* java/lang/Runtime.java (exitNoChecks): New method.
(exitNoChecksAccessor): Likewise.
(exit): Call exitNoChecks.
Index: gnu/java/lang/natMainThread.cc
===================================================================
--- gnu/java/lang/natMainThread.cc (revision 112665)
+++ gnu/java/lang/natMainThread.cc (working copy)
@@ -57,6 +57,5 @@
_Jv_ThreadWait ();
int status = (int) ::java::lang::ThreadGroup::had_uncaught_exception;
- ::java::lang::Runtime *runtime = ::java::lang::Runtime::getRuntime ();
- runtime->exit (status);
+ ::java::lang::Runtime::exitNoChecksAccessor (status);
}
Index: java/lang/Runtime.java
===================================================================
--- java/lang/Runtime.java (revision 112665)
+++ java/lang/Runtime.java (working copy)
@@ -146,9 +146,20 @@
SecurityManager sm = SecurityManager.current; // Be thread-safe!
if (sm != null)
sm.checkExit(status);
+ exitNoChecks(status);
+ }
+ // Accessor to avoid adding a vtable slot.
+ static void exitNoChecksAccessor(int status)
+ {
+ current.exitNoChecks(status);
+ }
+
+ // Private since we can't add a vtable slot in 4.1.x.
+ private void exitNoChecks(int status)
+ {
if (runShutdownHooks())
- halt(status);
+ exitInternal(status);
// Someone else already called runShutdownHooks().
// Make sure we are not/no longer in the shutdownHooks set.
@@ -171,7 +182,7 @@
// while finalization for exit is going on and the status is non-zero
// we halt immediately.
if (status != 0)
- halt(status);
+ exitInternal(status);
while (true)
try
Index: testsuite/libjava.lang/pr26990.java
===================================================================
--- testsuite/libjava.lang/pr26990.java (revision 0)
+++ testsuite/libjava.lang/pr26990.java (revision 0)
@@ -0,0 +1,13 @@
+public class pr26990
+{
+ public static void main (String args[]) throws Exception
+ {
+ System.setSecurityManager(new SecurityManager()
+ {
+ public void checkExit(int status)
+ {
+ throw new SecurityException("This is a bug");
+ }
+ });
+ }
+}
Index: testsuite/libjava.lang/pr26990.out
===================================================================
Index: prims.cc
===================================================================
--- prims.cc (revision 112665)
+++ prims.cc (working copy)
@@ -1381,7 +1381,7 @@
("Exception during runtime initialization"));
t->printStackTrace();
if (runtime)
- runtime->exit (1);
+ java::lang::Runtime::exitNoChecksAccessor (1);
// In case the runtime creation failed.
::exit (1);
}