JDK-8126338 : Set icon on macos causes crash
  • Type: Bug
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: 7u6
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2012-06-25
  • Updated: 2015-06-17
  • Resolved: 2012-06-26
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7u6Fixed
Related Reports
Relates :  
Description
When we set an icon to our stage with the following code :

stage.getIcons().add(loadImage(new Image ("link_to_image"));

the application doesn't start .

We get the following excpetion (FX2Launcher is the name of our main class) :

Process: FX2Launcher [9926]
Path: /Applications/FX2Launcher.app/Contents/MacOS/JavaAppLauncher
Identifier: javafx.xxxx.xxxx.main.FX2Launcher
Version: 1.0 (1)
Code Type: X86-64 (Native)
Parent Process: launchd [220]

Exception Type: EXC_BAD_ACCESS (SIGABRT)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000008

VM Regions Near 0x8:
-->
__TEXT 0000000100000000-0000000100002000 [ 8K] r-x/rwx SM=COW /Applications/FX2Launcher.app/Contents/MacOS/JavaAppLauncher

Application Specific Information:
objc[9926]: garbage collection is OFF
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff907ebf56 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff8e48bd5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff907ebd8a +[NSException raise:format:arguments:] + 106
3 CoreFoundation 0x00007fff907ebd14 +[NSException raise:format:] + 116
4 Foundation 0x00007fff8c03ee40 -[NSURL(NSURL) initFileURLWithPath:] + 78
5 Foundation 0x00007fff8c03edd9 +[NSURL(NSURL) fileURLWithPath:] + 47
6 libglass.dylib 0x000000010eb02513 Java_com_sun_glass_ui_mac_MacWindow__1setIcon + 611
7 ??? 0x0000000104811f90 0x0 + 4370538384
8 ??? 0x0000000104806158 0x0 + 4370489688
9 ??? 0x0000000104806158 0x0 + 4370489688
10 ??? 0x0000000104806806 0x0 + 4370491398
)

terminate called throwing an exception
abort() called

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff90b90ce2 __pthread_kill + 10
1 libsystem_c.dylib 0x00007fff89b207d2 pthread_kill + 95
2 libsystem_c.dylib 0x00007fff89b11a7a abort + 143
3 libc++abi.dylib 0x00007fff89c307bc abort_message + 214
4 libc++abi.dylib 0x00007fff89c2dfcf default_terminate() + 28
5 libobjc.A.dylib 0x00007fff8e48c1b9 _objc_terminate + 94
6 libc++abi.dylib 0x00007fff89c2e001 safe_handler_caller(void (*)()) + 11
7 libc++abi.dylib 0x00007fff89c2e05c std::terminate() + 16
8 libc++abi.dylib 0x00007fff89c2f152 __cxa_throw + 114
9 libobjc.A.dylib 0x00007fff8e48be7a objc_exception_throw + 327
10 com.apple.CoreFoundation 0x00007fff907ebd8a +[NSException raise:format:arguments:] + 106
11 com.apple.CoreFoundation 0x00007fff907ebd14 +[NSException raise:format:] + 116
12 com.apple.Foundation 0x00007fff8c03ee40 -[NSURL(NSURL) initFileURLWithPath:] + 78
13 com.apple.Foundation 0x00007fff8c03edd9 +[NSURL(NSURL) fileURLWithPath:] + 47
14 libglass.dylib 0x000000010eb02513 Java_com_sun_glass_ui_mac_MacWindow__1setIcon + 611
15 ??? 0x0000000104811f90 0 + 4370538384
16 ??? 0x0000000104806158 0 + 4370489688
17 ??? 0x0000000104806158 0 + 4370489688
18 ??? 0x0000000104806806 0 + 4370491398
19 ??? 0x0000000104806158 0 + 4370489688
20 ??? 0x0000000104806158 0 + 4370489688
21 ??? 0x0000000104806158 0 + 4370489688
22 ??? 0x0000000104806158 0 + 4370489688
23 ??? 0x0000000104806158 0 + 4370489688
24 ??? 0x0000000104806158 0 + 4370489688
25 ??? 0x0000000104806158 0 + 4370489688
26 ??? 0x0000000104806158 0 + 4370489688
27 ??? 0x0000000104806806 0 + 4370491398
28 ??? 0x0000000104806806 0 + 4370491398
29 ??? 0x0000000104806806 0 + 4370491398
30 ??? 0x00000001048004f7 0 + 4370466039
31 libjvm.dylib 0x0000000103286eb3 JavaCalls::call_helper(JavaValue*, methodHandle*, JavaCallArguments*, Thread*) + 557
32 libjvm.dylib 0x0000000103286c80 JavaCalls::call(JavaValue*, methodHandle, JavaCallArguments*, Thread*) + 40
33 libjvm.dylib 0x00000001032a2727 _ZL20jni_invoke_nonstaticP7JNIEnv_P9JavaValueP8_jobject11JNICallTypeP10_jmethodIDP18JNI_ArgumentPusherP6Thread + 677
34 libjvm.dylib 0x000000010329648f jni_CallVoidMethod + 278
35 libglass.dylib 0x000000010eadfc09 -[GlassRunnable run] + 121
36 com.apple.CoreFoundation 0x00007fff907db70d -[NSObject performSelector:withObject:] + 61
37 com.apple.Foundation 0x00007fff8c069d70 __NSThreadPerformPerform + 214
38 com.apple.CoreFoundation 0x00007fff9075a4f1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
39 com.apple.CoreFoundation 0x00007fff90759d5d __CFRunLoopDoSources0 + 253
40 com.apple.CoreFoundation 0x00007fff90780b49 __CFRunLoopRun + 905
41 com.apple.CoreFoundation 0x00007fff90780486 CFRunLoopRunSpecific + 230
42 com.apple.HIToolbox 0x00007fff9507d4d3 RunCurrentEventLoopInMode + 277
43 com.apple.HIToolbox 0x00007fff950846d3 ReceiveNextEventCommon + 181
44 com.apple.HIToolbox 0x00007fff9508460e BlockUntilNextEventMatchingListInMode + 62
45 com.apple.AppKit 0x000000010000ce31 _DPSNextEvent + 659
46 com.apple.AppKit 0x000000010000c735 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
47 com.apple.AppKit 0x0000000100009071 -[NSApplication run] + 470
48 libglass.dylib 0x000000010eae06f7 -[GlassApplication runLoop:] + 1287
49 com.apple.CoreFoundation 0x00007fff907db70d -[NSObject performSelector:withObject:] + 61
50 com.apple.Foundation 0x00007fff8c069d70 __NSThreadPerformPerform + 214
51 com.apple.CoreFoundation 0x00007fff9075a4f1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
52 com.apple.CoreFoundation 0x00007fff90759d5d __CFRunLoopDoSources0 + 253
53 com.apple.CoreFoundation 0x00007fff90780b49 __CFRunLoopRun + 905
54 com.apple.CoreFoundation 0x00007fff90780486 CFRunLoopRunSpecific + 230
55 com.oracle.java.7u06.jdk 0x0000000101ae091c CreateExecutionEnvironment + 871
56 com.oracle.java.7u06.jdk 0x0000000101adb10c JLI_Launch + 1952
57 javafx.xxxx.xxxx.main.FX2Launcher 0x0000000100001a33 launch + 2572
58 javafx.xxxx.xxxx.main.FX2Launcher 0x0000000100000f94 main + 76
59 javafx.xxxx.xxxx.main.FX2Launcher 0x0000000100000f40 start + 52




Comments
verified in 2.2.0b16
09-07-2012

Thanks val! Turns out Mac Window.setIcon implementation requires that the window's title is set, which in this use case was not. Simple fix coming.
26-06-2012

The test case is just to create a stage and to set an icon with stage.getIcons().add I builded without any problems exactly the same code on linux and windows : link is not null, is not missing and I have no special characters.
26-06-2012

Turns out the window title must be set for the setIcon to work, so if it's not set yet we explicitly set it to "Untitled"
25-06-2012

Without the actual test case I can;t actually verify, but I can make the code more robust to cover all these potential cases outlined above.
25-06-2012

My initial guess is that the link is either NULL or points either to missing file, or has special characters that need to be resolved.
25-06-2012

Setting a Stage icon on the Mac has other problems (See RT-18254) but it shouldn't crash the application.
25-06-2012