You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Regis Xu (JIRA)" <ji...@apache.org> on 2009/02/17 04:07:59 UTC

[jira] Commented: (HARMONY-6091) [classlib][luni] - read closed socket cause vm crash

    [ https://issues.apache.org/jira/browse/HARMONY-6091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12674089#action_12674089 ] 

Regis Xu commented on HARMONY-6091:
-----------------------------------

This patch causes test case test_getInputStream failed at: 
            // No exception when reading a closed stream
            assertEquals(-1, in.read());

seems RI check EOF before reading: if already reach EOF, read always return -1 on Windows, but on Linux, we could never readch EOF, instead, SocketException is throwed. I'll file another JIRA for EOF checking.

> [classlib][luni] - read closed socket cause vm crash
> ----------------------------------------------------
>
>                 Key: HARMONY-6091
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6091
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M8
>            Reporter: Regis Xu
>             Fix For: 5.0M9
>
>         Attachments: HARMONY-6091.diff
>
>
> run the test case:
> public void test_close() throws IOException {
>         // Simple read/write test over the IO streams
>         final ServerSocket pingServer = new ServerSocket(0);
>         Runnable runnable = new Runnable() {
>             public void run() {
>                 try {
>                     Socket worker = pingServer.accept();
>                     pingServer.close();
>                     InputStream in = worker.getInputStream();
>                     in.read();
>                     OutputStream out = worker.getOutputStream();
>                     out.write(new byte[42]);
>                     worker.close();
>                 } catch (IOException e) {
>                     fail(e.getMessage());
>                 }
>             }
>         };
>         Thread thread = new Thread(runnable, "Socket.getInputStream");
>         thread.start();
>         Socket pingClient = new Socket(InetAddress.getLocalHost(), pingServer
>                 .getLocalPort());
>         // Busy wait until the client is connected.
>         int c = 0;
>         while (!pingClient.isConnected()) {
>             try {
>                 Thread.sleep(200);
>             } catch (InterruptedException e) {
>             }
>             if (++c > 4) {
>                 fail("thread is not alive");
>             }
>         }
>         // Write some data to the server to provoke it
>         OutputStream out = pingClient.getOutputStream();
>         out.write(new byte[256]);
>         InputStream in = pingClient.getInputStream();
>         in.read(new byte[42]);
>         // No exception when reading a closed stream
>         in.close();
>         try {
>             in.read();
>             fail("should throw SocketException");
>         } catch (SocketException e) {
>             // expected
>         }
>         pingClient.close();
>         pingServer.close();
>     }
> vm crashed:
> Signal reported: GENERAL_PROTECTION_FAULT
> Registers:
>     EAX: 0xffffffff, EBX: 0xb7f646d8, ECX: 0xffffffff, EDX: 0x00000001
>     ESI: 0xa6708d6c, EDI: 0xa6708f10, ESP: 0xbfd4bac8, EBP: 0xbfd4bb00
>     EIP: 0xb7f597e8
> Command line:
> /home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/java -classpath /home/bahamut/workspace/sandbox:/home/bahamut/eclipse/plugins/org.junit_3.8.1/junit.jar:/home/bahamut/eclipse/plugins/org.eclipse.jdt.junit_3.2.0.v20060605-1400/junitsupport.jar:/home/bahamut/eclipse/plugins/org.eclipse.jdt.junit.runtime_3.2.0.v20060605-1400/junitruntime.jar org.eclipse.jdt.internal.junit.runner.RemoteTestRunner -version 3 -port 37759 -testLoaderClass org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader -classNames SocketInputStream 
> Working directory:
> /home/bahamut/workspace/sandbox
> Environment variables:
> GREP_COLOR=auto
> GPG_AGENT_INFO=/tmp/seahorse-rOKbLn/S.gpg-agent:9861:1
> SHELL=/bin/bash
> DESKTOP_STARTUP_ID=
> TERM=xterm-256color
> XDG_SESSION_COOKIE=e17a10b63cc571e36810390047982e5e-1232596022.78545-2120527474
> GTK_RC_FILES=/etc/gtk/gtkrc:/home/bahamut/.gtkrc-1.2-gnome2
> WINDOWID=37855233
> ANT_HOME=/home/bahamut/apache-ant-1.7.0
> ANT_OPTS=-Xms256m -Xmx1024m -XX:MaxPermSize=256m
> SVN_EDITOR=/home/bahamut/git_workspace/bin/emacsclient.editor
> USER=bahamut
> LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:
> SSH_AUTH_SOCK=/tmp/keyring-Pje9Sb/ssh
> GNOME_KEYRING_SOCKET=/tmp/keyring-Pje9Sb/socket
> SESSION_MANAGER=local/Harmony-L3NEK37:/tmp/.ICE-unix/9774
> USERNAME=bahamut
> PATH=.::/home/bahamut/javacc-4.0/bin:/home/bahamut/git_workspace/bin:/home/bahamut/emacs.cvs/emacs-bin/bin:/home/bahamut/download/jdks/pxi3260sr3-20081106_07-sdk/jre/bin:/home/bahamut/apache-ant-1.7.0/bin:/home/bahamut/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
> DESKTOP_SESSION=default
> GDM_XSERVER_LOCATION=local
> PWD=/home/bahamut/harmony/federated
> JAVA_HOME=/home/bahamut/download/jdks/pxi3260sr3-20081106_07-sdk
> EDITOR=/home/bahamut/git_workspace/bin/emacsclient.editor
> LANG=en_US.UTF-8
> GNOME_KEYRING_PID=9773
> GDM_LANG=en_US.UTF-8
> PS1=${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(__git_ps1 " \[\033[32m[%s]\033[0m\]")
> $ 
> GDMSESSION=default
> HISTCONTROL=ignoreboth
> SHLVL=1
> HOME=/home/bahamut
> GNOME_DESKTOP_SESSION_ID=Default
> LOGNAME=bahamut
> XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/
> DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-Dms8zMdO0T,guid=2b27026fa3cf5b15dd478d5e4977ec37
> LESSOPEN=| /usr/bin/lesspipe %s
> WINDOWPATH=7
> DISPLAY=:0.0
> LESSCLOSE=/usr/bin/lesspipe %s %s
> COLORTERM=gnome-terminal
> XAUTHORITY=/home/bahamut/.Xauthority
> OLDPWD=/home/bahamut/harmony/federated/working_jdktools
> _=/home/bahamut/eclipse/eclipse
> IBM_JAVA_COMMAND_LINE=/home/bahamut/download/jdks/pxi3260sr3-20081106_07-sdk/jre/bin/java -Xms40m -Xmx256m -jar /home/bahamut/eclipse/startup.jar -os linux -ws gtk -arch x86 -launcher /home/bahamut/eclipse/eclipse -name Eclipse -showsplash 600 -exitdata 440009 -vm /home/bahamut/download/jdks/pxi3260sr3-20081106_07-sdk/jre/bin/java -vmargs -Xms40m -Xmx256m -jar /home/bahamut/eclipse/startup.jar
> LD_LIBRARY_PATH=/home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/default:/home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/:
> Loaded modules:
> /home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/java:
> 	0x08048000:0x0804d000
> 	0x0804d000:0x0804e000
> [heap]:
> 	0x0804e000:0x08696000
> /home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/libhyniochar.so:
> 	0x95e8e000:0x95fe0000
> 	0x95fe0000:0x96008000
> /home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/libhyarchive.so:
> 	0x96008000:0x96015000
> 	0x96015000:0x96016000
> /home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/libhyluni.so:
> 	0x96016000:0x96049000
> 	0x96049000:0x9604a000
> /home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/libhyzlib.so:
> 	0x9604a000:0x9605a000
> 	0x9605a000:0x9605b000
> /home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/default/libgc_gen_uncomp.so:
> 	0xb6467000:0xb64b8000
> 	0xb64b8000:0xb64b9000
> /home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/default/libjitrino.so:
> 	0xb64bb000:0xb6700000
> 	0xb6700000:0xb670d000
> /home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/default/libem.so:
> 	0xb6770000:0xb6799000
> 	0xb6799000:0xb679a000
> /lib/tls/i686/cmov/libnss_files-2.7.so:
> 	0xb681a000:0xb6823000
> 	0xb6823000:0xb6825000
> /lib/tls/i686/cmov/libnsl-2.7.so:
> 	0xb6825000:0xb6839000
> 	0xb6839000:0xb683b000
> /lib/tls/i686/cmov/libnss_compat-2.7.so:
> 	0xb683d000:0xb6844000
> 	0xb6844000:0xb6846000
> /home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/default/libvmi.so:
> 	0xb6851000:0xb6855000
> 	0xb6855000:0xb6856000
> /usr/lib/libstdc++.so.5.0.7:
> 	0xb697a000:0xb6a2a000
> 	0xb6a2a000:0xb6a2f000
> /home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/default/libicudata.so.34:
> 	0xb6a34000:0xb72a2000
> 	0xb72a2000:0xb72a3000
> /usr/lib/libxml2.so.2.6.31:
> 	0xb72a3000:0xb73bd000
> 	0xb73bd000:0xb73c2000
> /usr/lib/libz.so.1.2.3.3:
> 	0xb73c3000:0xb73d7000
> 	0xb73d7000:0xb73d8000
> /home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/libhynio.so:
> 	0xb73db000:0xb73dd000
> 	0xb73dd000:0xb73de000
> /lib/tls/i686/cmov/libnss_nis-2.7.so:
> 	0xb73de000:0xb73e6000
> 	0xb73e6000:0xb73e8000
> /home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/default/libicuuc.so.34:
> 	0xb73e8000:0xb74d8000
> 	0xb74d8000:0xb74df000
> /home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/default/libharmonyvm.so:
> 	0xb74df000:0xb764b000
> 	0xb764b000:0xb76ab000
> /usr/lib/locale/en_US.utf8/LC_CTYPE:
> 	0xb78e1000:0xb7920000
> /usr/lib/locale/en_US.utf8/LC_NUMERIC:
> 	0xb7920000:0xb7921000
> /usr/lib/locale/en_US.utf8/LC_COLLATE:
> 	0xb7921000:0xb7a02000
> /home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/default/libch.so:
> 	0xb7a02000:0xb7a0e000
> 	0xb7a0e000:0xb7a6c000
> /lib/libgcc_s.so.1:
> 	0xb7ca2000:0xb7cac000
> 	0xb7cac000:0xb7cad000
> /lib/tls/i686/cmov/libpthread-2.7.so:
> 	0xb7cae000:0xb7cc2000
> 	0xb7cc2000:0xb7cc4000
> /lib/tls/i686/cmov/librt-2.7.so:
> 	0xb7cc6000:0xb7ccd000
> 	0xb7ccd000:0xb7ccf000
> /usr/lib/libstdc++.so.6.0.9:
> 	0xb7ccf000:0xb7db7000
> 	0xb7db7000:0xb7dba000
> 	0xb7dba000:0xb7dbc000
> /lib/tls/i686/cmov/libdl-2.7.so:
> 	0xb7dc2000:0xb7dc4000
> 	0xb7dc4000:0xb7dc6000
> /lib/tls/i686/cmov/libm-2.7.so:
> 	0xb7dc6000:0xb7de9000
> 	0xb7de9000:0xb7deb000
> /lib/tls/i686/cmov/libc-2.7.so:
> 	0xb7deb000:0xb7f34000
> 	0xb7f34000:0xb7f35000
> 	0xb7f35000:0xb7f37000
> /usr/lib/locale/en_US.utf8/LC_TIME:
> 	0xb7f3b000:0xb7f3c000
> /usr/lib/locale/en_US.utf8/LC_MONETARY:
> 	0xb7f3c000:0xb7f3d000
> /usr/lib/locale/en_US.utf8/LC_MESSAGES/SYS_LC_MESSAGES:
> 	0xb7f3d000:0xb7f3e000
> /usr/lib/locale/en_US.utf8/LC_PAPER:
> 	0xb7f3e000:0xb7f3f000
> /usr/lib/locale/en_US.utf8/LC_NAME:
> 	0xb7f3f000:0xb7f40000
> /usr/lib/locale/en_US.utf8/LC_ADDRESS:
> 	0xb7f40000:0xb7f41000
> /usr/lib/locale/en_US.utf8/LC_TELEPHONE:
> 	0xb7f41000:0xb7f42000
> /usr/lib/locale/en_US.utf8/LC_MEASUREMENT:
> 	0xb7f42000:0xb7f43000
> /usr/lib/gconv/gconv-modules.cache:
> 	0xb7f43000:0xb7f4a000
> /usr/lib/locale/en_US.utf8/LC_IDENTIFICATION:
> 	0xb7f4a000:0xb7f4b000
> /home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/libhyprt.so:
> 	0xb7f4b000:0xb7f64000
> 	0xb7f64000:0xb7f68000
> /home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/libhythr.so:
> 	0xb7f68000:0xb7f83000
> 	0xb7f83000:0xb7f84000
> [vdso]:
> 	0xb7fb6000:0xb7fb7000
> /lib/ld-2.7.so:
> 	0xb7fb7000:0xb7fd1000
> 	0xb7fd1000:0xb7fd3000
> [stack]:
> 	0xbfd4c000:0xbfd4e000
> Stack trace:
>   0: 0xb7f597e8  hysock_read (hysock.c:2491)
>   1: 0x9603450e  Java_org_apache_harmony_luni_platform_OSNetworkSystem_readDirect (OSNetworkSystem.c:391)
>   2: 0x9603439c  Java_org_apache_harmony_luni_platform_OSNetworkSystem_read (OSNetworkSystem.c:341)
>   3: 0x9611ea18  stub::unknown
>   4: 0x9611e520  org/apache/harmony/luni/net/PlainSocketImpl::read (([BII)I): PlainSocketImpl.java:557
>   5: 0x95610659  org/apache/harmony/luni/net/SocketInputStream::read (()I): SocketInputStream.java:61
>   6: 0x95e5d9e6  SocketInputStream::test_getInputStream (()V): SocketInputStream.java:59
>   7: 0xb67da257   (:-1)
>   8: 0xb7553829  JIT_execute_method_default (ini_iA32.cpp:295)
>   9: 0xb6778018  DrlEMImpl::executeMethod(_jmethodID*, jvalue*, jvalue*) (DrlEMImpl.cpp:523)
>  10: 0xb6784f94  ExecuteMethod (em_intf.cpp:40)
>  11: 0xb754ecde  vm_execute_java_method_array (ini.cpp:61)
>  12: 0xb7578510  hythread_suspend_enable (hythread_ext.h:605)
>  13: 0xb75797b1  CallVoidMethodA(JNIEnv_External*, _jobject*, _jmethodID*, jvalue*) (jni_method.cpp:231)
>  14: 0xb7559258  invoke_primitive_method (java_lang_reflect_VMReflection.cpp:187)
>  15: 0x9560a92c  stub::unknown
>  16: 0x9560a827  java/lang/reflect/Method::invoke ((Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;): Method.java:317
>  17: 0x95e5d096  junit/framework/TestCase::runTest (()V): TestCase.java:154
>  18: 0x95e5cba5  junit/framework/TestCase::runBare (()V): TestCase.java:127
>  19: 0x95e5caf9  junit/framework/TestResult$1::protect (()V): TestResult.java:106
>  20: 0x95e5c9f4  junit/framework/TestResult::runProtected ((Ljunit/framework/Test;Ljunit/framework/Protectable;)V): TestResult.java:124
>  21: 0x95e5baf8  junit/framework/TestResult::run ((Ljunit/framework/TestCase;)V): TestResult.java:109
>  22: 0x95e5b9a4  junit/framework/TestCase::run ((Ljunit/framework/TestResult;)V): TestCase.java:118
>  23: 0x95e5b90a  junit/framework/TestSuite::runTest ((Ljunit/framework/Test;Ljunit/framework/TestResult;)V): TestSuite.java:208
>  24: 0x95e5b6ff  junit/framework/TestSuite::run ((Ljunit/framework/TestResult;)V): TestSuite.java:203
>  25: 0x95e5af8a  org/eclipse/jdt/internal/junit/runner/junit3/JUnit3TestReference::run ((Lorg/eclipse/jdt/internal/junit/runner/TestExecution;)V): JUnit3TestReference.java:128
>  26: 0x95e5ac85  org/eclipse/jdt/internal/junit/runner/TestExecution::run (([Lorg/eclipse/jdt/internal/junit/runner/ITestReference;)V): TestExecution.java:38
>  27: 0x95e533cb  org/eclipse/jdt/internal/junit/runner/RemoteTestRunner::runTests (([Ljava/lang/String;Ljava/lang/String;Lorg/eclipse/jdt/internal/junit/runner/TestExecution;)V): RemoteTestRunner.java:459
>  28: 0x95e531d2  org/eclipse/jdt/internal/junit/runner/RemoteTestRunner::runTests ((Lorg/eclipse/jdt/internal/junit/runner/TestExecution;)V): RemoteTestRunner.java:673
>  29: 0x95e50eb9  org/eclipse/jdt/internal/junit/runner/RemoteTestRunner::run (()V): RemoteTestRunner.java:386
>  30: 0x95e4e42c  org/eclipse/jdt/internal/junit/runner/RemoteTestRunner::main (([Ljava/lang/String;)V): RemoteTestRunner.java:196
>  31: 0xb67da257   (:-1)
>  32: 0xb7553829  JIT_execute_method_default (ini_iA32.cpp:295)
>  33: 0xb6778018  DrlEMImpl::executeMethod(_jmethodID*, jvalue*, jvalue*) (DrlEMImpl.cpp:523)
>  34: 0xb6784f94  ExecuteMethod (em_intf.cpp:40)
>  35: 0xb754ecde  vm_execute_java_method_array (ini.cpp:61)
>  36: 0xb75773d2  hythread_suspend_enable (hythread_ext.h:605)
>  37: 0xb75774c8  CallStaticVoidMethodV(JNIEnv_External*, _jobject*, _jmethodID*, char*) (jni_method.cpp:1552)
>  38: 0xb7577515  CallStaticVoidMethod(JNIEnv_External*, _jobject*, _jmethodID*, ...) (jni_method.cpp:1542)
>  39: 0x0804b004  main_runJavaMain (main.c:1341)
>  40: 0x08049cce  invocation (main.c:744)
>  41: 0x080492a8  gpProtectedMain (main.c:393)
>  42: 0x0804b725  main (cmain.c:140)
>  43: 0xb7e01450  __libc_start_main (??:-1)
>  44: 0xb7e01450  __libc_start_main (??:-1)
>  45: 0xb7e0137d  __libc_start_main (??:-1)
> <end of stack trace>
> Crashed module:
> /home/bahamut/harmony/hy.5.git/deploy/jdk/jre/bin/libhyprt.so
> (JNI native library)
> VM attached threads:
>     [0x95afdb90]  'ReaderThread'
>     [0x95b7eb90]  'ref handler'
>     [0x95bffb90]  'finalizer'
>     [0x95dccb90]  'finalizer'
>     [0x95e4db90]  'profiler thread'
> --->[0xb7ca18e0]  'main'
> seems we have not check the validation of socket before read it.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.