JDK-6553374 : "Permissions/receiveDataGramSocketTest" test case failed when "-Xcheck:jni" is used
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 1.4.2_14,1.4.2_15
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_10
  • CPU: x86
  • Submitted: 2007-05-03
  • Updated: 2011-01-19
  • Resolved: 2009-01-26
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other
1.4.2_19-rev b08Fixed 1.4.2_21Fixed
Related Reports
Relates :  
Relates :  
Description
"Permissions/receiveDataGramSocketTest" test case failed on Solaris 10 AMD64 when "-Xcheck:jni" is used.  Error message:
"
FATAL ERROR in native method: JNI call made with exception pending
        at java.net.PlainDatagramSocketImpl.peekData(Native Method)
        - locked <0xf2833c60> (a java.net.PlainDatagramSocketImpl)
        at java.net.DatagramSocket.receive(DatagramSocket.java:661)
        - locked <0xf2844ed0> (a java.net.DatagramPacket)
        - locked <0xf2832500> (a java.net.DatagramSocket)
        at myDataGramClient.run(myDataGramClient.java:18)
Abort
"

For reproduce it:
1. login to "stt-33.russia.sun.com"
2. cd /net/vice.russia/export/home0/dtf/dtf_ws/dtf3-exec/142_Suites-142_14b06_security_Sol10_x64-2007-05-03-18-17-08-0942/results/reguser.Solaris.x86/receiveDataGramSocketTest
3. perform test:
[stt-robot@stt-33]$ /export/JDK/j2sdk1.4.2_14/bin/java -Xbootclasspath:privileged.jar:/export/JDK/j2sdk1.4.2_14/jre/lib/rt.jar -Xcheck:jni -Djava.security.manager -Djava.security.policy=noSocketPermission.jp receiveDataGramSocketTest void false
FATAL ERROR in native method: JNI call made with exception pending
        at java.net.PlainDatagramSocketImpl.peekData(Native Method)
        - locked <0xf2833c60> (a java.net.PlainDatagramSocketImpl)
        at java.net.DatagramSocket.receive(DatagramSocket.java:661)
        - locked <0xf2844ed0> (a java.net.DatagramPacket)
        - locked <0xf2832500> (a java.net.DatagramSocket)
        at myDataGramClient.run(myDataGramClient.java:18)
Abort
4. If you remove -Xcheck:jni you can see:
"
[stt-robot@stt-33]$ /export/JDK/j2sdk1.4.2_14/bin/java -Xbootclasspath:privileged.jar:/export/JDK/j2sdk1.4.2_14/jre/lib/rt.jar -Djava.security.manager -Djava.security.policy=noSocketPermission.jp receiveDataGramSocketTest void false        -----------------------------------

Test Name   = receiveDataGramSocketTest
Test Args   = void Expected Result = false
Test Result = PASS: the test got Security exception as expected
"

platform: amd 64
OS: Solaris 10
JDK: 142_14 all builds
testing machine: stt-33.russia.sun.com
results in:
net/vice.russia/export/home0/dtf/dtf_ws/dtf3-exec/142_Suites-142_14b06_security_Sol10_x64-2007-05-03-18-17-08-0942/results/

Comments
SUGGESTED FIX *** src/solaris/native/java/net/PlainDatagramSocketImpl.c- Wed Apr 11 15:32:52 2007 --- src/solaris/native/java/net/PlainDatagramSocketImpl.c Mon Jun 11 12:10:13 2007 *** 1,9 **** /* ! * @(#)PlainDatagramSocketImpl.c 1.94 05/05/26 * ! * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ #include <errno.h> #include <netinet/in.h> --- 1,9 ---- /* ! * %W% %E% * ! * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ #include <errno.h> #include <netinet/in.h> *** 693,702 **** --- 693,704 ---- int orig_errno = errno; (void) recv(fd, fullPacket, 1, 0); errno = orig_errno; } #endif + (*env)->SetIntField(env, packet, dp_offsetID, 0); + (*env)->SetIntField(env, packet, dp_lengthID, 0); if (errno == ECONNREFUSED) { JNU_ThrowByName(env, JNU_JAVANETPKG "PortUnreachableException", "ICMP Port Unreachable"); } else { if (errno == EBADF) { *** 703,719 **** JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed"); } else { NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed"); } } (*env)->SetIntField(env, packet, dp_offsetID, 0); (*env)->SetIntField(env, packet, dp_lengthID, 0); - } else if (n == JVM_IO_INTR) { JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException", "operation interrupted"); - (*env)->SetIntField(env, packet, dp_offsetID, 0); - (*env)->SetIntField(env, packet, dp_lengthID, 0); } else { /* * success - fill in received address... * * REMIND: Fill in an int on the packet, and create inetadd --- 705,719 ---- JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed"); } else { NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed"); } } + } else if (n == JVM_IO_INTR) { (*env)->SetIntField(env, packet, dp_offsetID, 0); (*env)->SetIntField(env, packet, dp_lengthID, 0); JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException", "operation interrupted"); } else { /* * success - fill in received address... * * REMIND: Fill in an int on the packet, and create inetadd *** 905,914 **** --- 905,916 ---- /* truncate the data if the packet's length is too small */ if (n > packetBufferLen) { n = packetBufferLen; } if (n == JVM_IO_ERR) { + (*env)->SetIntField(env, packet, dp_offsetID, 0); + (*env)->SetIntField(env, packet, dp_lengthID, 0); if (errno == ECONNREFUSED) { JNU_ThrowByName(env, JNU_JAVANETPKG "PortUnreachableException", "ICMP Port Unreachable"); } else { if (errno == EBADF) { *** 915,931 **** JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed"); } else { NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed"); } } (*env)->SetIntField(env, packet, dp_offsetID, 0); (*env)->SetIntField(env, packet, dp_lengthID, 0); - } else if (n == JVM_IO_INTR) { JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException", "operation interrupted"); - (*env)->SetIntField(env, packet, dp_offsetID, 0); - (*env)->SetIntField(env, packet, dp_lengthID, 0); } else { int port; jobject packetAddress; /* --- 917,931 ---- JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed"); } else { NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed"); } } + } else if (n == JVM_IO_INTR) { (*env)->SetIntField(env, packet, dp_offsetID, 0); (*env)->SetIntField(env, packet, dp_lengthID, 0); JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException", "operation interrupted"); } else { int port; jobject packetAddress; /*
18-06-2007

EVALUATION Duplicated with 6273094 and 6231286. So need to backport the fixes into 1.4.2 if needed.
14-05-2007