hang in Lion
Henri Gomez
henri.gomez at gmail.com
Wed Nov 30 06:21:57 PST 2011
Hi Charles
Just tried with latest build of OpenJDK 7 for OSX
(http://openjdk-osx-build.googlecode.com/files/OpenJDK-OSX-1.7-universal-jdk-b219-20111130.dmg)
:
openjdk version "1.7.0-b219"
OpenJDK Runtime Environment (build 1.7.0-b219-20111130)
OpenJDK 64-Bit Server VM (build 21.0-b17, mixed mode)
Compiled and run with OpenJDK 7 :
Started
Awaiting complete...
Thread started Thread-0
Thread started Thread-1
Thread-0: 10000
Thread-1: 20000
Thread-0: 30000
Thread-0: 40000
Thread-1: 50000
Thread-1: 60000
Thread-1: 70000
Thread-1: 80000
Thread-1: 90000
Thread-1: 100000
Thread-0: 110000
Thread-0: 120000
Thread-1: 130000
Thread-0: 140000
Thread-1: 150000
Thread-0: 160000
Thread-0: 170000
Thread-0: 180000
Thread done Thread-1
Thread-0: 190000
Thread-0: 200000
Thread done Thread-0
Completed...
Tried on latest Apple Java 6 (1.6.0-29) and rebuilt Foo with it :
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-10M3527)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)
Started
Thread started Thread-1
Thread started Thread-2
Awaiting complete...
Thread-2: 10000
Thread-1: 20000
Thread-1: 30000
Thread-2: 40000
Thread-2: 50000
Thread-1: 60000
Thread-1: 70000
Thread-2: 80000
Thread-2: 90000
Thread-1: 100000
Thread-1: 110000
Thread-2: 120000
Thread-1: 130000
Thread-1: 140000
Thread-1: 150000
Thread-1: 160000
Thread-1: 170000
Thread-2: 180000
Thread-2: 190000
Thread-1: 200000
Thread done Thread-2
Thread done Thread-1
Completed...
Tried on both SnowLeopard and Lion machines.
Cheers
2011/11/30 Charles K Pepperdine <kirk at kodewerk.com>:
> Hi,
>
> I've got a chunk of code that mysteriously hangs on my new i7 Air running Lion. This code was given to me by a friend that is also running Lion. We've given it to another person that is also running Lion. I'm using 1.6.0_26-b02-383. It doesn't hang all the time and it doesn't hang on my older i7 17" MBP running Snow Leopard. It's also been tested on other MBP's running Snow Leopard without hanging. Forcing a core dump after the hang gave us this.
>
>> Thread 24: Java: Thread-1
>> 0 libSystem.B.dylib 0x00007fff89f88d7a mach_msg_trap + 10
>> 1 libSystem.B.dylib 0x00007fff89f893ed mach_msg + 59
>> 2 libclient64.dylib 0x000000010100d903 jio_snprintf + 37641
>> 3 libclient64.dylib 0x000000010100d7c3 jio_snprintf + 37321
>> 4 libclient64.dylib 0x000000010100d722 jio_snprintf + 37160
>> 5 libclient64.dylib 0x000000010100c5ad jio_snprintf + 32691
>> 6 libclient64.dylib 0x000000010100c4ef jio_snprintf + 32501
>> 7 libclient64.dylib 0x00000001011afefd JVM_GetClassInterfaces + 12075
>> 8 libclient64.dylib 0x00000001010a7c8c JVM_Lseek + 204251
>> 9 libclient64.dylib 0x00000001010a7bea JVM_Lseek + 204089
>> 10 libclient64.dylib 0x00000001011b4931 JVM_Socket + 5319
>> 11 ??? 0x000000010380f0e7 0 + 4353749223
>> 12 ??? 0x000000010386fd90 0 + 4354145680
>>
>> Thread 25: Java: Thread-2
>> 0 libSystem.B.dylib 0x00007fff89f88d7a mach_msg_trap + 10
>> 1 libSystem.B.dylib 0x00007fff89f893ed mach_msg + 59
>> 2 libclient64.dylib 0x000000010100db03 jio_snprintf + 38153
>> 3 libclient64.dylib 0x00000001010cb569 JVM_Write + 9130
>> 4 libclient64.dylib 0x00000001011ddfcd JVM_NanoTime + 39179
>> 5 ??? 0x000000010386ea60 0 + 4354140768
>
> All of the other thread could be attributed to VM processes (GC, compiler etc...).
>
> On my machine, the hang seems to only happen when thread-2 finishes before thread-1. I've never seen it hang when thread-1 finishes before thread-2 Again it doesn't hang all the time when thread-2 finishes first. This is a hard hang in that I can only get rid of the process with a kill -9. ^C and kill simply don't to anything.
>
> Code follows,
>
> Regards,
> Kirk Pepperdine
>
> public class Foo {
>
> private int counter;
>
> public static void main(String[] args) throws Exception {
> new Foo().run();
> }
>
> public void run() throws Exception {
>
> Thread[] threads = new Thread[2];
>
> for (int i = 0; i < threads.length; i++) {
> threads[i] = new Thread() {
> public void run() {
>
> System.out.println("Thread started " + Thread.currentThread().getName());
> System.out.flush();
>
> for (int i = 0; i < 100000; i++) {
> increment();
> }
>
> System.out.println("Thread done " + Thread.currentThread().getName());
> System.out.flush();
> }
> };
> }
>
> for (Thread t : threads) {
> t.start();
> }
>
> System.out.println("Started");
> System.out.flush();
>
> System.out.println("Awaiting complete...");
> System.out.flush();
>
> for (Thread t : threads) {
> t.join();
> }
>
> System.out.println("Completed...");
> System.out.flush();
> }
>
> private synchronized void increment() {
>
> counter++;
>
> if (counter % 10000 == 0) {
> System.out.printf("%s: %d\n", Thread.currentThread().getName(), counter);
> System.out.flush();
> }
> }
> }
More information about the macosx-port-dev
mailing list