JavaGaming.org

March 18, 2010, 11:56:31 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
Advanced search  
Pages: [1]   Go Down
Print
Author Topic: Thread launching quirks on Apple Java  (Read 2906 times)
0 Members and 2 Guests are viewing this topic.
Riven
Guest
« on: September 27, 2008, 04:08:14 pm »

If you run this as an applet on Apple Java, you might be surprised.

Code:
System.out.println("A");

new Thread(){public void run(){ System.out.println("1"); }}.start();

System.out.println("B");

Runnable r = new Runnable(){public void run(){ System.out.println("2"); }};
int stackSize = 32*1024;
new Thread(null, r, "name", stackSize).start();

System.out.println("C");




For me it prints A, B, C and 1... Roll Eyes
Logged
tom
JGO Neuromancer
*******
Offline Offline

Gender: Male
Posts: 1015



View Profile WWW
« Reply #1 on: September 27, 2008, 04:20:14 pm »

So "2" is never printed. Have you tried any of the other Thread constructors?
Logged

Riven
Guest
« Reply #2 on: September 27, 2008, 04:24:23 pm »

Well, they all redirect to / call the most explicit constructor.


So for all constructors, eventually the same path is taken, only the arguments are different.

I think the problem is that the stackSize is very small. The Javadoc says the behaviour on explicitly setting this value is very VM implementation dependant, but not executing the Thread at all is not really following the intention of the spec, eh.

« Last Edit: September 27, 2008, 05:07:12 pm by Riven » Logged
Demonpants
Global Moderator
JGO Kernel
*****
Offline Offline

Gender: Male
Posts: 2244


Looking For Work


View Profile WWW
« Reply #3 on: September 27, 2008, 05:35:44 pm »

Well that's no good... I don't like to use threads because they get so complicated.

You could be using synchronized!
Logged

See my work:
OTC Software


Current Project(s):
Agent: 00PK
Voodoo Vendetta
Riven
Guest
« Reply #4 on: September 28, 2008, 02:28:40 am »

Could anybody with a Mac please test the above code, just to be sure I don't have either corrupt software or hardware.
Logged
Mr. Gol
Full Member
***
Offline Offline

Gender: Male
Posts: 171



View Profile
« Reply #5 on: September 28, 2008, 02:39:15 am »

Tested on Core 2 Duo Macbook, Mac OS X 10.5.5, Java 6:

Code:
A
B
1
C
Invalid memory access of location fffffff8 rip=010f374c

What the ... ?!
Logged
Riven
Guest
« Reply #6 on: September 28, 2008, 02:45:39 am »

Thank you VERY much for confirming!


This is a serious bug!
Logged
Demonpants
Global Moderator
JGO Kernel
*****
Offline Offline

Gender: Male
Posts: 2244


Looking For Work


View Profile WWW
« Reply #7 on: September 28, 2008, 11:17:08 am »

Code:
A
B
1
C

Program exited with status 0.

Whoops.
Logged

See my work:
OTC Software


Current Project(s):
Agent: 00PK
Voodoo Vendetta
ewjordan
Full Member
***
Offline Offline

Posts: 230


View Profile
« Reply #8 on: September 28, 2008, 04:16:04 pm »

(Edit: oops, these results are from running this snippet as an application, not an applet; I should have read Riven's first post more carefully, I'll try running as an applet later)

Using the various Apple JVMs:
1.5:
Code:
A
B
1
C
1.6 beta:
Code:
A
B
1
C
Invalid memory access of location fffffff8 rip=010a19e6
#
# An unexpected Java error has been detected by HotSpot Virtual Machine.
#
# If this error is reproducible, please report it with the following information:
#   1. Provide the steps to reproduce, a test case, and any relevant information
#   2. The corresponding JavaNativeCrash_pid<num>.crash.log (Java state)
#   3. The corresponding <name>.crash.log (native state; generated by CrashReporter)
#   4. This data:
#
# Java VM: Java HotSpot(TM) 64-Bit Server VM (1.6.0_04-b12-45-optimized mixed mode)
# An unexpected error has been detected by Java Runtime Environment:
#
#  Bus Error (0xa) at pc=0x00000001010a19e6#
#  Bus Error (0xa) at pc=0x00000001010a19e6, pid=16027, tid=4300226560
#
# Java VM: Java HotSpot(TM) 64-Bit Server VM (1.6.0_04-b12-45-optimized mixed mode macosx-amd64)
# An error report file with more information is saved as:
# /Users/eric/Library/Logs/Java/JavaNativeCrash_pid16027.crash.log
#
#
# File report at: http://bugreport.apple.com/
#

And, for good measure, I tried with 1.4 as well:
Code:
A
B
C
1
2

Looks like things have gotten worse as the version number increases...

Out of curiosity, could someone post results with Sun JVMs?
« Last Edit: September 28, 2008, 04:17:51 pm by ewjordan » Logged
Demonpants
Global Moderator
JGO Kernel
*****
Offline Offline

Gender: Male
Posts: 2244


Looking For Work


View Profile WWW
« Reply #9 on: September 28, 2008, 06:59:40 pm »

It's interesting that 1.4 works better. My result above is from 1.5.
Logged

See my work:
OTC Software


Current Project(s):
Agent: 00PK
Voodoo Vendetta
Riven
Guest
« Reply #10 on: September 28, 2008, 10:52:15 pm »

All Sun VMs (Windows, Linux) work fine

1.4.2, 1.5, 1.6
Logged
Mr. Gol
Full Member
***
Offline Offline

Gender: Male
Posts: 171



View Profile
« Reply #11 on: September 29, 2008, 02:26:56 am »

I posted this problem on the Apple Java mailing list, with a link to this thread (http://lists.apple.com/archives/Java-dev/2008/Sep/msg00457.html). Since Apple's Java team actually reads this list, and replies to it, there should be a fairly large chance of an 'official' reply in the next week or so.
Logged
Riven
Guest
« Reply #12 on: September 29, 2008, 03:13:12 am »

In Java 1.5 it certainly does not crash the entire JVM. It just does not execute the Thread. My applet keeps functioning.
Logged
Mr. Gol
Full Member
***
Offline Offline

Gender: Male
Posts: 171



View Profile
« Reply #13 on: September 30, 2008, 12:24:24 am »

We have a reply, it is indeed a bug:
http://lists.apple.com/archives/Java-dev/2008/Sep/msg00471.html

I already reported it into their issue tracking system.
Logged
Demonpants
Global Moderator
JGO Kernel
*****
Offline Offline

Gender: Male
Posts: 2244


Looking For Work


View Profile WWW
« Reply #14 on: September 30, 2008, 09:18:25 am »

Wow what a truly fluid response. Prolific, you might say.  Roll Eyes
Logged

See my work:
OTC Software


Current Project(s):
Agent: 00PK
Voodoo Vendetta
Riven
Guest
« Reply #15 on: September 30, 2008, 10:10:12 am »

Bedankt Dennis!



Any chance to see the progress in the issuetracker, like a tracking id?
« Last Edit: September 30, 2008, 10:14:28 am by Riven » Logged
Mr. Gol
Full Member
***
Offline Offline

Gender: Male
Posts: 171



View Profile
« Reply #16 on: October 01, 2008, 12:49:16 am »

I reported it under Bug ID# 6256466, but it seems Apple's issue tracker doesn't allow public access to issues.

@Demonpants: We had to wait 18 months before Apple released Java 6, which created the question if they would even continue their Java support at all. So getting ANY sort of reply on a Java-related matter is already a miracle. I think the chance of Steve Jobs responding to my mailing list post is fairly low.

@Riven: Are you Dutch? Smiley
Logged
Riven
Guest
« Reply #17 on: October 01, 2008, 11:20:15 am »

@Riven: Are you Dutch? Smiley

Yup yup yup, even living quite near you.
Logged
Mr. Gol
Full Member
***
Offline Offline

Gender: Male
Posts: 171



View Profile
« Reply #18 on: September 09, 2009, 09:22:57 am »

One of Apple's Jva guys contacted me to inform me that this bug has been fixed in their Java Update 5, which was released last week. So compliments to Riven for finding something that they rank as 'serious issue' Smiley
Logged
Riven
JGO Neuromancer
*******
Online Online

Gender: Male
Posts: 1229


Colorblind. 120bpm


View Profile WWW
« Reply #19 on: September 09, 2009, 02:48:49 pm »

So many emotions....!


bored     persecutioncomplex     immortal

                         Roll Eyes
Logged

Pages: [1]   Go Up
Print
 
Jump to: