Java-Gaming.org
Java4K - to go         Javadoc:
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, peek at the official java tutorials or join us at irc #jgo.
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  Thread launching quirks on Apple Java  (Read 4477 times)
0 Members and 1 Guest are viewing this topic.
Online Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5509
Medals: 204


Hand over your head.


« on: 2008-09-27 19:08:14 »

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

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
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

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline tom

JGO Neuromancer
****

Posts: 1091
Medals: 3



« Reply #1 on: 2008-09-27 19:20:14 »

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

Online Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5509
Medals: 204


Hand over your head.


« Reply #2 on: 2008-09-27 19:24:23 »

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.


Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Games published by our own members! Go get 'em!
Offline Eli Delventhal
« League of Dukes »

JGO Kernel
*****

Posts: 3478
Medals: 39


Game Engineer


« Reply #3 on: 2008-09-27 20:35:44 »

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

You could be using synchronized!

See my work:
OTC Software
<br />
Currently Working On:
Secret project...
Quote from: _Riven
I edit JGO in production, because I simply don't waste time writing bugs
Online Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5509
Medals: 204


Hand over your head.


« Reply #4 on: 2008-09-28 05:28:40 »

Could anybody with a Mac please test the above code, just to be sure I don't have either corrupt software or hardware.

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline Mr. Gol

Full Member
**

Posts: 213
Medals: 1



« Reply #5 on: 2008-09-28 05:39:15 »

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

1  
2  
3  
4  
5  
A
B
1
C
Invalid memory access of location fffffff8 rip=010f374c


What the ... ?!
Online Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5509
Medals: 204


Hand over your head.


« Reply #6 on: 2008-09-28 05:45:39 »

Thank you VERY much for confirming!


This is a serious bug!

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline Eli Delventhal
« League of Dukes »

JGO Kernel
*****

Posts: 3478
Medals: 39


Game Engineer


« Reply #7 on: 2008-09-28 14:17:08 »

1  
2  
3  
4  
5  
6  
A
B
1
C

Program exited with status 0.


Whoops.

See my work:
OTC Software
<br />
Currently Working On:
Secret project...
Quote from: _Riven
I edit JGO in production, because I simply don't waste time writing bugs
Offline ewjordan

Sr. Member
**

Posts: 255



« Reply #8 on: 2008-09-28 19:16:04 »

(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:
1  
2  
3  
4  
A
B
1
C

1.6 beta:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
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:
1  
2  
3  
4  
5  
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?
Offline Eli Delventhal
« League of Dukes »

JGO Kernel
*****

Posts: 3478
Medals: 39


Game Engineer


« Reply #9 on: 2008-09-28 21:59:40 »

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

See my work:
OTC Software
<br />
Currently Working On:
Secret project...
Quote from: _Riven
I edit JGO in production, because I simply don't waste time writing bugs
Games published by our own members! Go get 'em!
Online Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5509
Medals: 204


Hand over your head.


« Reply #10 on: 2008-09-29 01:52:15 »

All Sun VMs (Windows, Linux) work fine

1.4.2, 1.5, 1.6

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline Mr. Gol

Full Member
**

Posts: 213
Medals: 1



« Reply #11 on: 2008-09-29 05:26:56 »

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.
Online Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5509
Medals: 204


Hand over your head.


« Reply #12 on: 2008-09-29 06:13:12 »

In Java 1.5 it certainly does not crash the entire JVM. It just does not execute the Thread. My applet keeps functioning.

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline Mr. Gol

Full Member
**

Posts: 213
Medals: 1



« Reply #13 on: 2008-09-30 03:24:24 »

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.
Offline Eli Delventhal
« League of Dukes »

JGO Kernel
*****

Posts: 3478
Medals: 39


Game Engineer


« Reply #14 on: 2008-09-30 12:18:25 »

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

See my work:
OTC Software
<br />
Currently Working On:
Secret project...
Quote from: _Riven
I edit JGO in production, because I simply don't waste time writing bugs
Online Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5509
Medals: 204


Hand over your head.


« Reply #15 on: 2008-09-30 13:10:12 »

Bedankt Dennis!



Any chance to see the progress in the issuetracker, like a tracking id?

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline Mr. Gol

Full Member
**

Posts: 213
Medals: 1



« Reply #16 on: 2008-10-01 03:49:16 »

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
Online Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5509
Medals: 204


Hand over your head.


« Reply #17 on: 2008-10-01 14:20:15 »

@Riven: Are you Dutch? Smiley

Yup yup yup, even living quite near you.

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline Mr. Gol

Full Member
**

Posts: 213
Medals: 1



« Reply #18 on: 2009-09-09 12:22:57 »

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
Online Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5509
Medals: 204


Hand over your head.


« Reply #19 on: 2009-09-09 17:48:49 »

So many emotions....!


bored     persecutioncomplex     immortal

                         Roll Eyes

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.105 seconds with 21 queries.