United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6203567 NameService resolving in Applet causes AccessControlException and deadlock
6203567 : NameService resolving in Applet causes AccessControlException and deadlock

Details
Type:
Bug
Submit Date:
2004-12-03
Status:
Open
Updated Date:
2012-07-20
Project Name:
JDK
Resolved Date:
Component:
other-libs
OS:
linux,generic,windows_2000
Sub-Component:
corba:idl
CPU:
x86,generic
Priority:
P4
Resolution:
Unresolved
Affected Versions:
5.0,6
Targeted Versions:
7

Related Reports
Duplicate:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Linux mjirko 2.4.18-14 #1 Wed Sep 4 13:35:50 EDT 2002 i686 athlon i386 GNU/Linux
Microsoft Windows 2000 [Verze 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
NameService resolving (calling ORB.resolve_initial_references("NameService")) in Apllet causes AccessControlException and deadlock (applet hangs).

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- run name service (on port 2809):  tnameserv -ORBInitialPort 2809
- run test applet using appleviewer:  appletviewer CorbaTest.html

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
NameSrvice should be resolved and message "Nameservice resolved." printed into System.out.
ACTUAL -
The applet hangs in ORB.resolve_initial_references().

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "Thread-2" java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThread)
        at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
        at java.security.AccessController.checkPermission(AccessController.java:427)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
        at sun.applet.AppletSecurity.checkAccess(AppletSecurity.java:138)
        at java.lang.Thread.checkAccess(Thread.java:1218)
        at java.lang.Thread.setName(Thread.java:1001)
        at com.sun.corba.se.impl.transport.SelectorImpl.run(SelectorImpl.java:239)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
<!-- FILE: CorbaTest.html -->
<HTML>
  <HEAD>
    <TITLE>CORBA Test</TITLE>
  </HEAD>
  <BODY>
    <h1>CORBA Test</h1>
    <hr>
    <applet code="CorbaTest.class" width="400" height="250">
      <param name="org.omg.CORBA.ORBInitialPort" value="2809"/>
      alt="Your browser understands the &lt;APPLET&gt; tag but isn't running the applet, for some reason."
      Your browser is completely ignoring the &lt;APPLET&gt; tag!
    </applet>
  </BODY>
</HTML>


/**
 * FILE: CorbaTest.java
 */
import java.applet.Applet;
import org.omg.CORBA.*;
import org.omg.CosNaming.*;

public class CorbaTest extends Applet {

  private ORB orb;

  public void init() {
    // create ORB
    try {
      orb = ORB.init(this, null);
      //((com.sun.corba.se.spi.orb.ORB) orb).transportDebugFlag = true;
    } catch(RuntimeException e) { }
  }

 public void start() {
    if(orb==null) return;
    // resolve NamingContext
    try {
      org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
      NamingContext nc = NamingContextHelper.narrow(objRef);
      System.out.println("NameService resolved.");
    } catch(Exception e) { }
  }

  public void destroy() {
    if(orb!=null) {
      orb.shutdown(false);
      orb = null;
    }
  }

}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Grant "modifyThread" and "modifyThreadGroup" permissions to Applet.
Suggested fix supplied by community member ###@###.###:

A DESCRIPTION OF THE FIX :
  Bug number : 6203567
  Bug Description : NameService resolving in Applet causes AccessControlException and deadlock
Diff Baseline : Tiger  b05
Diff :
--- com/sun/corba/se/impl/transport/SelectorImpl.java   2005-08-26 22:54:33.000000000 +0200
+++ com/sun/corba/se/impl/transport/SelectorImpl2.java  2005-11-10 10:23:42.000000000 +0100
@@ -236,7 +236,12 @@

     public void run()
     {
-       setName("SelectorThread");
+       AccessController.doPrivileged(new PrivilegedAction() {
+           public Object run() {
+               setName("SelectorThread");
+               return null;
+           }
+       });
        while (!closed) {
            try {
                int n = 0;

FIX FOR BUG NUMBER:
6203567
Test case supplied by community member ###@###.###:

Hello,

here is a little test case for the fix.  Steps to use this test case:

1) compile CorbaInAppletTest.java
2) run name service (on port 2809):  tnameserv -ORBInitialPort 2809
3) run the test applet using appleviewer:  appletviewer 
CorbaInAppletTest.html

If the bug is present, the exception message is printed out and the 
apllet hangs in ORB.resolve_initial_references().
If the bug is corrected, NameSrvice should be resolved and message 
"Nameservice resolved." printed into System.out.


Refer to the attached files for CorbaInAppletTest.java and CorbaInAppletTest.html

                                    

Comments
EVALUATION

Contribution-Forum:https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?messageID=12008&forumID=1463
                                     
2006-03-15
EVALUATION

Yes, this should be fixed. We plan on fixing it for the next update release of Java SE 5.0.
                                     
2005-11-18



Hardware and Software, Engineered to Work Together