[rfc][icedtea-web] More shutdown fixes -- Interrupt applet threads after shutdown, fix NPE
Adam Domurad
adomurad at redhat.com
Thu Feb 21 08:31:31 PST 2013
On 02/13/2013 03:44 PM, Adam Domurad wrote:
> ChangeLog:
>
> 2013-02-13 Adam Domurad <adomurad at redhat.com>
>
> Interrupt applet threads that did not finish on normal shutdown.
> Prevent
> NPE that can occur from sun.applet.AppletPanel.
> * netx/net/sourceforge/jnlp/NetxPanel.java
> (destroyApplet): interrupt applet threads
> * netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
> (getPermissions): avoid potential NPE if code source location is
> missing
>
>
>
> 1.) The NPE:
>
> I had previously posted a patch for an NPE that only occurred during
> shutdown, but I had not looked into it too deeply.
>
> Now I see the cause is:
>
> sun.applet.AppletPanel.java:
>
> private AccessControlContext getAccessControlContext(final URL
> codebase) {
>
> PermissionCollection perms = (PermissionCollection)
> AccessController.doPrivileged(new PrivilegedAction() {
> public Object run() {
> Policy p = java.security.Policy.getPolicy();
> if (p != null) {
> >>> return p.getPermissions(new
> CodeSource(null, <<<
> (java.security.cert.Certificate[]) null));
> } else {
> return null;
> }
> }
> });
>
> This occurs in PluginAppletViewer#appletShutdown, when
> p.sendEvent(AppletPanel.APPLET_QUIT); is used. A null source location
> must thus be supported as such:
>
> diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
> b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
> --- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
> +++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
> @@ -1144,7 +1144,7 @@ public class JNLPClassLoader extends URL
> }
>
> // Class from host X should be allowed to connect to host X
> - if (cs.getLocation().getHost().length() > 0)
> + if (cs.getLocation() != null &&
> cs.getLocation().getHost().length() > 0)
> result.add(new
> SocketPermission(cs.getLocation().getHost(),
> "connect, accept"));
>
>
> 2.) Threads seem to sometimes leak when icedtea-web is refreshed. In
> fact, this is the cause of an out-of-memory-error I was seeing a while
> back. ITW had ~ 1000 threads kicking around because they were not
> properly disposed of.
>
> This interrupts all remaining threads, after joining with the applets
> main thread. This will be enough to shut down most threads (and fixed
> the issue I was seeing with horaoficial). It's hard to think of
> anything further that can be done, save for lots of interrupts in
> quick succession. Causing thread death was considered, but it can
> cause stability problems, I think.
>
>
Looks like we need another method for interrupting threads, this method
caused some problems in my testing.
I will come back to this, however I would very much like this NPE fix to
get in, thanks.
-Adam
More information about the distro-pkg-dev
mailing list