Bug 10886 - The RMI registry that comes with GCJ does not work correctly
Summary: The RMI registry that comes with GCJ does not work correctly
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libgcj (show other bugs)
Version: 3.3
: P2 critical
Target Milestone: 3.3.1
Assignee: Jeff Sturm
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2003-05-20 21:36 UTC by agreene
Modified: 2003-07-25 16:34 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-05-23 19:09:32


Attachments
example.zip (24.25 KB, application/x-zip )
2003-05-21 15:17 UTC, agreene
Details
RMI/serialization patch (503 bytes, patch)
2003-05-23 19:07 UTC, Jeff Sturm
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description agreene 2003-05-20 21:36:00 UTC
The problem is most likely two fold:

The first being, this line:

System.setSecurityManager(new RMISecurityManager());

Which causes this error:

java.rmi.UnexpectedException: undeclared checked exception; nested exception is:
        java.lang.IllegalArgumentException: Bad permission name:  enableSubtitution
   at _ZN4java4lang11VMThrowable16fillInStackTraceEPNS0_9ThrowableE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java4lang9Throwable16fillInStackTraceEv (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java4lang9ThrowableC1EPNS0_6StringE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java4lang9ExceptionC1EPNS0_6StringE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java2io11IOExceptionC1EPNS_4lang6StringE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java3rmi15RemoteExceptionC1EPNS_4lang6StringEPNS2_9ThrowableE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java3rmi19UnexpectedExceptionC1EPNS_4lang6StringEPNS2_9ExceptionE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN3gnu4java3rmi8registry17RegistryImpl_Stub6rebindEPN4java4lang6StringEPNS4_3rmi6RemoteE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java3rmi6Naming6rebindEPNS_4lang6StringEPNS0_6RemoteE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN3gnu3gcj7runtime11FirstThread9call_mainEv (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN3gnu3gcj7runtime11FirstThread3runEv (/usr/local/lib/libgcj.so.4.0.0)
   at _Z13_Jv_ThreadRunPN4java4lang6ThreadE (/usr/local/lib/libgcj.so.4.0.0)
   at _Z11_Jv_RunMainPN4java4lang5ClassEPKciPS4_b (/usr/local/lib/libgcj.so.4.0.0)
   at JvRunMain (/usr/local/lib/libgcj.so.4.0.0)
   at __libc_start_main (/lib/libc-2.2.5.so)
   at _start (Unknown Source)
Caused by: java.lang.IllegalArgumentException: Bad permission name:  enableSubtitution
   at _ZN4java4lang11VMThrowable16fillInStackTraceEPNS0_9ThrowableE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java4lang9Throwable16fillInStackTraceEv (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java4lang9ThrowableC1EPNS0_6StringE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java4lang9ExceptionC1EPNS0_6StringE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java4lang16RuntimeExceptionC1EPNS0_6StringE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java4lang24IllegalArgumentExceptionC1EPNS0_6StringE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java2io22SerializablePermissionC1EPNS_4lang6StringES4_ (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java2io22SerializablePermissionC1EPNS_4lang6StringE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java2io17ObjectInputStream19enableResolveObjectEb (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN3gnu4java3rmi6server20RMIObjectInputStreamC1EPN4java2io11InputStreamE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN3gnu4java3rmi6server17UnicastConnection20getObjectInputStreamEv (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN3gnu4java3rmi6server17UnicastRemoteCall14getInputStreamEv (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN3gnu4java3rmi6server17UnicastRemoteCall11executeCallEv (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN3gnu4java3rmi6server10UnicastRef6invokeEPN4java3rmi6server10RemoteCallE (/usr/local/lib/libgcj.so.4.0.0)
   ...9 more

But once that line is removed, the following occurs:

If you use the rmiregistry program that is created by GCC 3.3 (I did a new install and compiled GCC 3.3), and run the provided server and client against it (server source is com.romulin.rmi.RMIServerImpl and client source is com.romulin.rmi.TestClient), it produces the following:

java.rmi.UnexpectedException: undeclared checked exception; nested exception is:
        java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
   at _ZN4java4lang11VMThrowable16fillInStackTraceEPNS0_9ThrowableE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java4lang9Throwable16fillInStackTraceEv (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java4lang9ThrowableC1EPNS0_6StringE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java4lang9ExceptionC1EPNS0_6StringE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java2io11IOExceptionC1EPNS_4lang6StringE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java3rmi15RemoteExceptionC1EPNS_4lang6StringEPNS2_9ThrowableE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java3rmi19UnexpectedExceptionC1EPNS_4lang6StringEPNS2_9ExceptionE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN3gnu4java3rmi8registry17RegistryImpl_Stub6rebindEPN4java4lang6StringEPNS4_3rmi6RemoteE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN4java3rmi6Naming6rebindEPNS_4lang6StringEPNS0_6RemoteE (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN3gnu3gcj7runtime11FirstThread9call_mainEv (/usr/local/lib/libgcj.so.4.0.0)
   at _ZN3gnu3gcj7runtime11FirstThread3runEv (/usr/local/lib/libgcj.so.4.0.0)
   at _Z13_Jv_ThreadRunPN4java4lang6ThreadE (/usr/local/lib/libgcj.so.4.0.0)
   at _Z11_Jv_RunMainPN4java4lang5ClassEPKciPS4_b (/usr/local/lib/libgcj.so.4.0.0)
   at JvRunMain (/usr/local/lib/libgcj.so.4.0.0)
   at __libc_start_main (/lib/libc-2.2.5.so)
   at _start (Unknown Source)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
   <<No stacktrace available>>

The example will throw this error and then create it's own RMI registry and the client will work.  This error does not occur when you use the rmiregistry from Sun JDK 1.4.1_02 (that is, everything functions as expected, except the problem with Security as stated above as it affect RMIServerImpl under Sun's JDK as well).

Release:
GCJ-3.3

Environment:
Slackware Linux 8.1 default setup (no previous GCJ)

How-To-Repeat:
rmiregistry 1099 &
./server & -- error is thrown
Comment 1 Jeff Sturm 2003-05-23 04:24:22 UTC
The permissions bug is fixed in libgcj/10838.

I've confirmed the ArrayIndexOutOfBounds exception on mainline.
Comment 2 Jeff Sturm 2003-05-23 19:07:02 UTC
Created attachment 4061 [details]
RMI/serialization patch

Can you try the attached patch?  Your example worked for me with this patch on
mainline.

I'm not positive the returnValue() fix is correct, I don't know RMI that well. 
Moreover the RMI in libgcj isn't tested much at all.  If you have RMI apps you
could try on it that'd be a big help.
Comment 3 agreene 2003-05-26 16:22:28 UTC
Well, the suggested patch seems to work for me (didn't throw the exception).  I 
don't want to assume anything, but... well... it worked :->
Comment 4 Jeff Sturm 2003-06-08 01:37:10 UTC
Patch applied to mainline.