Skip site navigation (1)Skip section navigation (2)
Date:      17 Nov 2007 17:15:12 +0100
From:      "Arno J. Klaassen" <arno@heho.snv.jussieu.fr>
To:        java@freebsd.org
Cc:        current@freebsd.org
Subject:   mutex-bug in recent releng_[67]?
Message-ID:  <wpfxz497cf.fsf@heho.snv.jussieu.fr>

index | next in thread | raw e-mail

[-- Attachment #1 --]
I have serious problems with " Runtime.getRuntime ().exec ()" : either
it hangs or gives a spinning mutex running at 99% cpu.

Attached is a simple code-example which shows the problem : it basically
just launces in iterations a process doing "/bin/ls -lRr /var/"
(the command seems to be important : e.g. ps(1) works fine, ls(1), tar(1),
cpio(1) (all doing fileio ...) fail more or less easiliy) 
and then waits for it to exit.

This works OK with linux-sun-jdk15, it fails (most often just hang,
something process ends with exit code 127) on all boxes I could test on :

 i686-releng_6-UP / jdk-1.5.0.13p7,1
 i686-releng_7-UP / jdk-1.5.0.12p6_2,1
 amd64-releng_6-SMP / jdk-1.5.0.12p6_2,1 and jdk-1.5.0.13p7,1
 amd64-releng_7-SMP / jdk-1.5.0.13p7,1


I somehow doubt this is really (only) a jdk-problem : it fails (hangs)
as well if I compile it with gcj to an executable (tested both on
 i686-releng_6-UP and amd64-releng_7-SMP).

Attached a gdb-log (for releng_7) with shows three threads, two of them
blocking in _umtx_op () (from pthread_cond_init () ), the third
in sigsuspend () (from pthread_getprio () ?).

If I create a core-dump with "gcore -s" all sixteen threads
block in (log attached for the two first threads ) :

  #0  0x00000008008cabfc in wait4 () from /lib/libc.so.7
  #1  0x000000080075616e in waitpid () from /lib/libthr.so.3
  #2  0x0000000801e43030 in Java_java_lang_UNIXProcess_waitForProcessExit (
      env=0x82c1a2998, junk=0x7ffffeef1798, pid=906)


I hope someone can help me for this, or should I write a PR?

Thanx very much in adavance.

Arno



[-- Attachment #2 --]


final class Test_proc
{
  Test_proc()
  {
    for (int i= 0; i < 2; i++)
      {
        System.out.println("test <" + i + ">: retval is <" 
            + fork_shell() + ">");
      }
  }

  private long fork_shell()
  {
    long ret = -1;
    int exit_value = 0;
    final String[] cmd = new String[3];
    final Process proc;

    cmd[0] = "/bin/sh";
    cmd[1] = "-c";
    cmd[2] = "/bin/ls -lRr /var/";

    try
      {
        proc = Runtime.getRuntime ().exec (cmd);

        proc.waitFor ();

        if ( (exit_value = proc.exitValue ()) != 0)
          {
            System.err.println ("ERROR: proc exit value" + exit_value + "!");
          }
        else ret=0;
    }
    catch (Exception ex)
      {
        ret = -2;
        ex.printStackTrace(System.err);
      }

    return ret;
  }


  public static void main (String[] args) throws Exception
  {
    new Test_proc ();
  }
}

[-- Attachment #3 --]
Script started on Sat Nov 17 16:22:55 2007
ivo@push ~/.scito/tmp [49908] > LD_LIBRARY_PATH=/usr/opt/scito/gcc-4.2.2/lib gdb  ./Test_proc.exe 
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...
(gdb) handle SIGSEGV SIGBUS nostop noprint
Signal        Stop	Print	Pass to program	Description
SIGBUS        No	No	Yes		Bus error
SIGSEGV       No	No	Yes		Segmentation fault
(gdb) r
Starting program: /files/home/ivo/.scito/tmp/Test_proc.exe 
[New LWP 100094]
[New Thread 0x803901120 (LWP 100094)]
[New Thread 0x803901290 (LWP 100127)]
[New Thread 0x803901400 (LWP 100132)]
^C
Program received signal SIGINT, Interrupt.
[Switching to Thread 0x803901400 (LWP 100132)]
0x00000008036e6c7c in sigsuspend () from /lib/libc.so.7
(gdb) info thr
* 4 Thread 0x803901400 (LWP 100132)  0x00000008036e6c7c in sigsuspend ()
   from /lib/libc.so.7
  3 Thread 0x803901290 (LWP 100127)  0x00000008036e60fc in _umtx_op ()
   from /lib/libc.so.7
  2 Thread 0x803901120 (LWP 100094)  0x00000008036e60fc in _umtx_op ()
   from /lib/libc.so.7
(gdb) thr 4
[Switching to thread 4 (Thread 0x803901400 (LWP 100132))]#0  0x00000008036e6c7c in sigsuspend () from /lib/libc.so.7
(gdb) where
#0  0x00000008036e6c7c in sigsuspend () from /lib/libc.so.7
#1  0x0000000803371c6a in sigsuspend () from /lib/libthr.so.3
#2  0x0000000801ce8d16 in java::lang::ConcreteProcess$ProcessManager::waitForSignal (this=Variable "this" is not available.
) at java/lang/natConcreteProcess.cc:142
#3  0x000000080202025d in _ZN4java4lang30ConcreteProcess$ProcessManager3runEJvv
    (this=0x599e60) at ConcreteProcess.java:167
#4  0x0000000801cee6a8 in _Jv_ThreadRun (thread=0x599e60)
    at ../../../../gcc/libjava/java/lang/natThread.cc:302
#5  0x0000000801cf4b37 in really_start (x=0x5265a0)
    at ../../../../gcc/libjava/posix-threads.cc:445
#6  0x00000008024da163 in GC_start_routine (arg=Variable "arg" is not available.
)
    at ../../../../gcc/boehm-gc/pthread_support.c:1301
#7  0x000000080336fa76 in pthread_getprio () from /lib/libthr.so.3
#8  0x0000000000000000 in ?? ()
Error accessing memory address 0x7fffff9fe000: Bad address.
(gdb) thr 3
[Switching to thread 3 (Thread 0x803901290 (LWP 100127))]#0  0x00000008036e60fc in _umtx_op () from /lib/libc.so.7
(gdb) where
#0  0x00000008036e60fc in _umtx_op () from /lib/libc.so.7
#1  0x0000000803377049 in pthread_cleanup_push () from /lib/libthr.so.3
#2  0x0000000803375a55 in pthread_cond_init () from /lib/libthr.so.3
#3  0x0000000801cf4ff2 in _Jv_CondWait (cv=0x8031da088, mu=0x8031da070, millis=Variable "millis" is not available.

) at ../../../../gcc/libjava/posix-threads.cc:179
#4  0x0000000801cdfd45 in gnu::gcj::runtime::FinalizerThread::run (this=Variable "this" is not available.
)
    at ../../../../gcc/libjava/gnu/gcj/runtime/natFinalizerThread.cc:57
#5  0x0000000801cee6a8 in _Jv_ThreadRun (thread=0x561e00)
    at ../../../../gcc/libjava/java/lang/natThread.cc:302
#6  0x0000000801cf4b37 in really_start (x=0x526720)
    at ../../../../gcc/libjava/posix-threads.cc:445
#7  0x00000008024da163 in GC_start_routine (arg=Variable "arg" is not available.
)
    at ../../../../gcc/boehm-gc/pthread_support.c:1301
#8  0x000000080336fa76 in pthread_getprio () from /lib/libthr.so.3
#9  0x0000000000000000 in ?? ()
Error accessing memory address 0x7fffffbff000: Bad address.
(gdb) thr 2
[Switching to thread 2 (Thread 0x803901120 (LWP 100094))]#0  0x00000008036e60fc in _umtx_op () from /lib/libc.so.7
(gdb) where
#0  0x00000008036e60fc in _umtx_op () from /lib/libc.so.7
#1  0x0000000803377049 in pthread_cleanup_push () from /lib/libthr.so.3
#2  0x0000000803375a55 in pthread_cond_init () from /lib/libthr.so.3
#3  0x0000000801cf4ff2 in _Jv_CondWait (cv=0x578cb0, mu=0x578cb8, millis=Variable "millis" is not available.
)
    at ../../../../gcc/libjava/posix-threads.cc:179
#4  0x0000000801ceab37 in java::lang::Object::wait (this=0x1, timeout=0, 
    nanos=0) at ../../../../gcc/libjava/java/lang/natObject.cc:1333
#5  0x00000008020206d8 in _ZN4java4lang15ConcreteProcess7waitForEJiv (
    this=0x59af60) at ConcreteProcess.java:324
#6  0x0000000000401771 in _ZN9Test_proc10fork_shellEJxv (this=0x54ade0)
    at Test_proc.java:29
#7  0x0000000000401467 in Test_proc.Test_proc() (this=0x54ade0)
    at Test_proc.java:10
#8  0x0000000000401982 in _ZN9Test_proc4mainEJvP6JArrayIPN4java4lang6StringEE (
    args=0x52af70) at Test_proc.java:49
#9  0x0000000801ce03c3 in gnu::java::lang::MainThread::call_main (
    this=0x599f00) at ../../../../gcc/libjava/gnu/java/lang/natMainThread.cc:50
#10 0x0000000801cee6a8 in _Jv_ThreadRun (thread=0x599f00)
    at ../../../../gcc/libjava/java/lang/natThread.cc:302
#11 0x0000000801cb1259 in _Jv_RunMain (vm_args=Variable "vm_args" is not available.
)
    at ../../../../gcc/libjava/prims.cc:1574
#12 0x000000000040139a in main (argc=1, argv=0x7fffffffead8)
    at /var/tmp//ccGmt6ri.i:11
(gdb) quit
The program is running.  Exit anyway? (y or n) y

[-- Attachment #4 --]
Script started on Sat Nov 17 17:00:46 2007
ivo@push ~/.scito/tmp [49909] > gdb -core core.905 /usr/local/jdk1.5.0/bin/java_g GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...
Core was generated by `java_g'.
Reading symbols from /lib/libz.so.4...done.
Loaded symbols for /lib/libz.so.4
Reading symbols from /lib/libthr.so.3...done.
Loaded symbols for /lib/libthr.so.3
Reading symbols from /lib/libc.so.7...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /usr/local/jdk1.5.0/jre/lib/amd64/server/libjvm_g.so...done.
Loaded symbols for /usr/local/jdk1.5.0/jre/lib/amd64/server/libjvm_g.so
Reading symbols from /usr/lib/libstdc++.so.6...done.
Loaded symbols for /usr/lib/libstdc++.so.6
Reading symbols from /lib/libm.so.5...done.
Loaded symbols for /lib/libm.so.5
Reading symbols from /lib/libgcc_s.so.1...done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /usr/local/jdk1.5.0/jre/lib/amd64/native_threads/libhpi_g.so...done.
Loaded symbols for /usr/local/jdk1.5.0/jre/lib/amd64/native_threads/libhpi_g.so
Reading symbols from /usr/local/jdk1.5.0/jre/lib/amd64/libverify_g.so...done.
Loaded symbols for /usr/local/jdk1.5.0/jre/lib/amd64/libverify_g.so
Reading symbols from /usr/local/jdk1.5.0/jre/lib/amd64/libjava_g.so...done.
Loaded symbols for /usr/local/jdk1.5.0/jre/lib/amd64/libjava_g.so
Reading symbols from /usr/local/jdk1.5.0/jre/lib/amd64/libzip_g.so...done.
Loaded symbols for /usr/local/jdk1.5.0/jre/lib/amd64/libzip_g.so
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x00000008008cabfc in wait4 () from /lib/libc.so.7
[New Thread 0x800b04d80 (LWP 100145)]
[New Thread 0x800b04c10 (LWP 100144)]
[New Thread 0x800b04aa0 (LWP 100143)]
[New Thread 0x800b04930 (LWP 100142)]
[New Thread 0x800b047c0 (LWP 100141)]
[New Thread 0x800b04650 (LWP 100140)]
[New Thread 0x800b044e0 (LWP 100139)]
[New Thread 0x800b03f20 (LWP 100138)]
[New Thread 0x800b03db0 (LWP 100137)]
[New Thread 0x800b033a0 (LWP 100136)]
[New Thread 0x800b01850 (LWP 100135)]
[New Thread 0x800b016e0 (LWP 100134)]
[New Thread 0x800b01570 (LWP 100127)]
[New Thread 0x800b01400 (LWP 100094)]
[New Thread 0x800b01120 (LWP 100054)]
[New LWP 905]
(gdb) info thr
* 16 LWP 905  0x00000008008cabfc in wait4 () from /lib/libc.so.7
  15 Thread 0x800b01120 (LWP 100054)  warning: Couldn't find general-purpose registers in core file.

0x00000008008cabfc in wait4 ()
   from /lib/libc.so.7
  14 Thread 0x800b01400 (LWP 100094)  warning: Couldn't find general-purpose registers in core file.

0x00000008008cabfc in wait4 ()
   from /lib/libc.so.7
  13 Thread 0x800b01570 (LWP 100127)  warning: Couldn't find general-purpose registers in core file.

0x00000008008cabfc in wait4 ()
   from /lib/libc.so.7
  12 Thread 0x800b016e0 (LWP 100134)  warning: Couldn't find general-purpose registers in core file.

0x00000008008cabfc in wait4 ()
   from /lib/libc.so.7
  11 Thread 0x800b01850 (LWP 100135)  warning: Couldn't find general-purpose registers in core file.

0x00000008008cabfc in wait4 ()
   from /lib/libc.so.7
  10 Thread 0x800b033a0 (LWP 100136)  warning: Couldn't find general-purpose registers in core file.

0x00000008008cabfc in wait4 ()
   from /lib/libc.so.7
  9 Thread 0x800b03db0 (LWP 100137)  warning: Couldn't find general-purpose registers in core file.

0x00000008008cabfc in wait4 ()
   from /lib/libc.so.7
  8 Thread 0x800b03f20 (LWP 100138)  warning: Couldn't find general-purpose registers in core file.

0x00000008008cabfc in wait4 ()
   from /lib/libc.so.7
  7 Thread 0x800b044e0 (LWP 100139)  warning: Couldn't find general-purpose registers in core file.

0x00000008008cabfc in wait4 ()
   from /lib/libc.so.7
  6 Thread 0x800b04650 (LWP 100140)  warning: Couldn't find general-purpose registers in core file.

0x00000008008cabfc in wait4 ()
   from /lib/libc.so.7
  5 Thread 0x800b047c0 (LWP 100141)  warning: Couldn't find general-purpose registers in core file.

0x00000008008cabfc in wait4 ()
   from /lib/libc.so.7
  4 Thread 0x800b04930 (LWP 100142)  warning: Couldn't find general-purpose registers in core file.

0x00000008008cabfc in wait4 ()
   from /lib/libc.so.7
  3 Thread 0x800b04aa0 (LWP 100143)  warning: Couldn't find general-purpose registers in core file.

0x00000008008cabfc in wait4 ()
   from /lib/libc.so.7
  2 Thread 0x800b04c10 (LWP 100144)  warning: Couldn't find general-purpose registers in core file.

0x00000008008cabfc in wait4 ()
   from /lib/libc.so.7
  1 Thread 0x800b04d80 (LWP 100145)  warning: Couldn't find general-purpose registers in core file.

0x00000008008cabfc in wait4 ()
   from /lib/libc.so.7
(gdb) where     thr 16
[Switching to thread 16 (LWP 905)]#0  0x00000008008cabfc in wait4 ()
   from /lib/libc.so.7
(gdb) where
#0  0x00000008008cabfc in wait4 () from /lib/libc.so.7
#1  0x000000080075616e in waitpid () from /lib/libthr.so.3
#2  0x0000000801e43030 in Java_java_lang_UNIXProcess_waitForProcessExit (
    env=0x82c1a2998, junk=0x7ffffeef1798, pid=906)
    at ../../../src/solaris/native/java/lang/UNIXProcess_md.c:303
#3  0x0000000804f1dbe0 in ?? ()
#4  0x0000000801669f50 in vtable for ThreadInVMfromJavaNoAsyncException ()
   from /usr/local/jdk1.5.0/jre/lib/amd64/server/libjvm_g.so
#5  0x0000000804f308bf in ?? ()
#6  0x00007ffffeef1620 in ?? ()
#7  0x00007ffffeef1738 in ?? ()
#8  0x00000008081eff48 in ?? ()
#9  0x00007ffffeef1798 in ?? ()
#10 0x00000008081f1dc0 in ?? ()
#11 0x0000000000000000 in ?? ()
#12 0x00000008081eff48 in ?? ()
#13 0x00007ffffeef1790 in ?? ()
#14 0x00007ffffeef17d8 in ?? ()
#15 0x0000000804f08e1a in ?? ()
#16 0x0000000000000000 in ?? ()
#17 0x0000000804f154d6 in ?? ()
#18 0x000000000000038a in ?? ()
#19 0x00000008217fb410 in ?? ()
#20 0x00007ffffeef17a0 in ?? ()
#21 0x00000008081f0eb2 in ?? ()
#22 0x00007ffffeef17f0 in ?? ()
#23 0x00000008081f1dc0 in ?? ()
#24 0x0000000000000000 in ?? ()
#25 0x00000008081f0ec0 in ?? ()
#26 0x00007ffffeef17e8 in ?? ()
#27 0x00007ffffeef1830 in ?? ()
#28 0x0000000804f08e1a in ?? ()
#29 0x000000000000038a in ?? ()
#30 0x00000008217fb410 in ?? ()
#31 0x00007ffffeef17f8 in ?? ()
#32 0x00000008081f4155 in ?? ()
#33 0x00007ffffeef1858 in ?? ()
#34 0x00000008081f4608 in ?? ()
#35 0x0000000000000000 in ?? ()
#36 0x00000008081f41b0 in ?? ()
#37 0x00007ffffeef1858 in ?? ()
#38 0x00007ffffeef18c0 in ?? ()
#39 0x0000000804f064ae in ?? ()
#40 0x0000000000000000 in ?? ()
#41 0x0000000000000000 in ?? ()
#42 0x0000000000000000 in ?? ()
#43 0x00000008217fb5c8 in ?? ()
#44 0x00007fff00001fa0 in ?? ()
#45 0x0000000000000000 in ?? ()
#46 0x0000000000000001 in ?? ()
#47 0x00007ffffeef1bc0 in ?? ()
#48 0x0000000000000001 in ?? ()
#49 0x0000000804f063a8 in ?? ()
#50 0x00007ffffeef1910 in ?? ()
#51 0x00007ffffeef1cb8 in ?? ()
#52 0x00007fff0000000a in ?? ()
#53 0x00000008081f41b0 in ?? ()
#54 0x0000000804f18e60 in ?? ()
#55 0x00007ffffeef1bc0 in ?? ()
#56 0x00007ffffeef1a20 in ?? ()
#57 0x00000008010a2dc4 in JavaCalls::call_helper (result=0x3d8, m=0xfffffff8, 
    args=0xe, __the_thread__=0x8012d1410)
    at /files/bsd/ports/java/jdk15/work/hotspot/src/share/vm/runtime/javaCalls.cpp:373
Previous frame inner to this frame (corrupt stack?)
(gdb) wherethr 16 5
warning: Couldn't find general-purpose registers in core file.

[Switching to thread 15 (Thread 0x800b01120 (LWP 100054))]#0  0x00000008008cabfc in wait4 () from /lib/libc.so.7
(gdb) thr 15where
#0  0x00000008008cabfc in wait4 () from /lib/libc.so.7
#1  0x000000080075616e in waitpid () from /lib/libthr.so.3
#2  0x0000000801e43030 in Java_java_lang_UNIXProcess_waitForProcessExit (
    env=0x82c1a2998, junk=0x7ffffeef1798, pid=906)
    at ../../../src/solaris/native/java/lang/UNIXProcess_md.c:303
#3  0x0000000804f1dbe0 in ?? ()
#4  0x0000000801669f50 in vtable for ThreadInVMfromJavaNoAsyncException ()
   from /usr/local/jdk1.5.0/jre/lib/amd64/server/libjvm_g.so
#5  0x0000000804f308bf in ?? ()
#6  0x00007ffffeef1620 in ?? ()
#7  0x00007ffffeef1738 in ?? ()
#8  0x00000008081eff48 in ?? ()
#9  0x00007ffffeef1798 in ?? ()
#10 0x00000008081f1dc0 in ?? ()
#11 0x0000000000000000 in ?? ()
#12 0x00000008081eff48 in ?? ()
#13 0x00007ffffeef1790 in ?? ()
#14 0x00007ffffeef17d8 in ?? ()
#15 0x0000000804f08e1a in ?? ()
#16 0x0000000000000000 in ?? ()
#17 0x0000000804f154d6 in ?? ()
#18 0x000000000000038a in ?? ()
#19 0x00000008217fb410 in ?? ()
#20 0x00007ffffeef17a0 in ?? ()
#21 0x00000008081f0eb2 in ?? ()
#22 0x00007ffffeef17f0 in ?? ()
#23 0x00000008081f1dc0 in ?? ()
#24 0x0000000000000000 in ?? ()
#25 0x00000008081f0ec0 in ?? ()
#26 0x00007ffffeef17e8 in ?? ()
#27 0x00007ffffeef1830 in ?? ()
#28 0x0000000804f08e1a in ?? ()
#29 0x000000000000038a in ?? ()
#30 0x00000008217fb410 in ?? ()
#31 0x00007ffffeef17f8 in ?? ()
#32 0x00000008081f4155 in ?? ()
#33 0x00007ffffeef1858 in ?? ()
#34 0x00000008081f4608 in ?? ()
#35 0x0000000000000000 in ?? ()
#36 0x00000008081f41b0 in ?? ()
#37 0x00007ffffeef1858 in ?? ()
#38 0x00007ffffeef18c0 in ?? ()
#39 0x0000000804f064ae in ?? ()
#40 0x0000000000000000 in ?? ()
#41 0x0000000000000000 in ?? ()
#42 0x0000000000000000 in ?? ()
#43 0x00000008217fb5c8 in ?? ()
#44 0x00007fff00001fa0 in ?? ()
#45 0x0000000000000000 in ?? ()
#46 0x0000000000000001 in ?? ()
#47 0x00007ffffeef1bc0 in ?? ()
#48 0x0000000000000001 in ?? ()
#49 0x0000000804f063a8 in ?? ()
#50 0x00007ffffeef1910 in ?? ()
#51 0x00007ffffeef1cb8 in ?? ()
#52 0x00007fff0000000a in ?? ()
#53 0x00000008081f41b0 in ?? ()
#54 0x0000000804f18e60 in ?? ()
#55 0x00007ffffeef1bc0 in ?? ()
#56 0x00007ffffeef1a20 in ?? ()
#57 0x00000008010a2dc4 in JavaCalls::call_helper (result=0x3d8, m=0xfffffff8, 
    args=0xe, __the_thread__=0x8012d1410)
    at /files/bsd/ports/java/jdk15/work/hotspot/src/share/vm/runtime/javaCalls.cpp:373
Previous frame inner to this frame (corrupt stack?)

[ idem all threads ]

[-- Attachment #5 --]
  Arno J. Klaassen

  SCITO S.A.
  8 rue des Haies
  F-75020 Paris, France
  http://scito.com

help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?wpfxz497cf.fsf>