hang in Lion
Charles K Pepperdine
kirk at kodewerk.com
Wed Nov 30 04:11:32 PST 2011
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