Issue580170

classification
Title: System.exit() causes Tomcat crash.
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: bmatlin, fwierzbicki, leouserz, trondandersen
Priority: low Keywords:

Created on 2002-07-11.16:27:21 by bmatlin, last changed 2008-11-03.22:13:20 by fwierzbicki.

Messages
msg683 (view) Author: Bob Matlin (bmatlin) Date: 2002-07-11.16:27:21
We're running jython within Tomcat. Due to a Python 
script programming error we ran into an 
OutOfMemoryError. Py.java handles this error by 
eventually calling System.exit(), which crashes Tomcat. 
In general, for the purpose of running jython from within 
another Java application it would be good to remove all 
the System.exit() calls. 

msg684 (view) Author: Deleted User leouserz (leouserz) Date: 2006-12-21.16:26:49
System.exit occurs in jython.java and Py.java.  Look at maybeExit and the SystemExit class and Py.java.

It would be great to have a test case that reproduces this.  From running this code in the interpreter:
>>> import java.lang as jl
>>> a = []
>>> for z in xrange(6000000):
...    a.append(jl.Long(z))

The OutOfMemory error is produced but it does not cause Jython to exit.

leouser

msg685 (view) Author: Trond Andersen (trondandersen) Date: 2007-02-11.00:40:00
This code exists in PyObject:

} catch (PyException e) {
    if (e.value instanceof PyJavaInstance) {
        Object t = e.value.__tojava__(Throwable.class);
        if (t != null && t != Py.NoConversion) {
            throw (Throwable) t;
        }
    } else {
        ThreadState ts = Py.getThreadState();
    if (ts.frame == null) {
        Py.maybeSystemExit(e);
    }
    if (Options.showPythonProxyExceptions) {
        Py.stderr.println(
             "Exception in Python proxy returning to Java:");
        Py.printException(e);
    }
}

This calls the maybeSystemExit() method which probably is a bad thing for the PyObject class given that so many classes inherit from this class. Could this be related to this bug?
msg3745 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2008-11-03.22:13:20
System.exit is never called for OutOfMemoryError -- maybe it once did.

System.exit is only called in the event of an actual explicit call to
exit from Python code (for example a call to exit()).  This is no more a
problem than having Java code call System.exit().
History
Date User Action Args
2008-11-03 22:13:20fwierzbickisetstatus: open -> closed
resolution: wont fix
messages: + msg3745
nosy: + fwierzbicki
2002-07-11 16:27:21bmatlincreate