Bug 500900 - MessageBox.open hangs if display is disposed and recreated
Summary: MessageBox.open hangs if display is disposed and recreated
Status: CLOSED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.6   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2016-09-06 05:20 EDT by Nam Quang Tran CLA
Modified: 2020-02-08 03:58 EST (History)
4 users (show)

See Also:


Attachments
Snippet to reproduce the problem (869 bytes, text/x-java)
2016-09-06 05:20 EDT, Nam Quang Tran CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nam Quang Tran CLA 2016-09-06 05:20:22 EDT
Created attachment 263982 [details]
Snippet to reproduce the problem

In the attached snippet, a display and shell are created, disposed, and then recreated. This somehow causes a MessageBox.open call to hang, without the message being shown. The hang was seen on Windows 7; in Ubuntu 14.04, the message is shown and then the program exits, as expected. On both operating systems, SWT 4.6 64-bit was used.
Comment 1 Niraj Modi CLA 2016-09-09 04:40:16 EDT
(In reply to Nam Quang Tran from comment #0)
> Created attachment 263982 [details]
> Snippet to reproduce the problem
> 
Unable to reproduce hang issue with attached snippet on Win7
Comment 2 Nam Quang Tran CLA 2016-09-09 07:00:00 EDT
My configuration:
- Windows 7 Ultimate SP1 64-Bit
- Oracle JDK 1.8.0_101 64-Bit
- Eclipse Neon 4.6.0, build ID 20160613-1800
- SWT 4.6 64-Bit. The version.txt inside the SWT jar says "version 4.623".

Discovered something interesting: The snippet hangs when run inside Eclipse, but does not hang if I export the test project as a runnable jar and then run the jar from the commandline with "java -jar test.jar". I don't remember having altered my project run configuration in any way.
Comment 3 Nam Quang Tran CLA 2016-09-09 07:07:07 EDT
Tested again with SWT 4.7M1 (version 4.706). Same results.
Comment 4 Sravan Kumar Lakkimsetti CLA 2016-09-09 07:46:56 EDT
@Niraj
I tried on fedora 24 I am not able to reproduce this.
Comment 5 Nam Quang Tran CLA 2016-09-09 08:37:50 EDT
Perhaps I should add that my Windows copy is running inside a VirtualBox machine. Not sure if that's relevant...
Comment 6 Nam Quang Tran CLA 2016-09-09 09:06:53 EDT
Running the snippet in debug mode with SWT 4.6 reveals that the program is stuck at OS.java:3051, which is the following line:

return MessageBoxW (hWnd, lpText1, lpCaption1, uType);
Comment 7 Nam Quang Tran CLA 2016-09-09 15:21:37 EDT
The complete call stack is probably more helpful; here it is:

OS.MessageBoxW(long, char[], char[], int) line: not available [native method]	
OS.MessageBox(long, TCHAR, TCHAR, int) line: 3051	
MessageBox.open() line: 206	
Test.main(String[]) line: 20
Comment 8 Nam Quang Tran CLA 2016-09-09 15:28:39 EDT
One more piece of information: The snippet was run in a fresh copy of "Eclipse IDE for Java Developers" without any additional plugins.
Comment 9 Nikita Nemkin CLA 2020-02-08 03:58:34 EST
The second MessageBox does appear, you can Alt+Tab to it. The problem is that the application loses foreground status after the first shell is disposed. The second MessageBox pops up in the background and is hard to notice.

I'm not sure about the other platforms, but this behavior is correct on Windows. If the application has no windows, it can't be in the foreground.