Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandr Miloslavskiy2019-10-07 09:17:15 +0000
committerAlexandr Miloslavskiy2019-10-07 09:40:50 +0000
commit243c98a07bf2e6ea32d7bf94afd727ef2259babb (patch)
tree14329a8ddc8f139d399dd7532133caff73d85db8 /tests/org.eclipse.swt.tests.win32
parent984aa15dcace16bd3db7bd0c252c2d333db20fa9 (diff)
downloadeclipse.platform.swt-243c98a07bf2e6ea32d7bf94afd727ef2259babb.tar.gz
eclipse.platform.swt-243c98a07bf2e6ea32d7bf94afd727ef2259babb.tar.xz
eclipse.platform.swt-243c98a07bf2e6ea32d7bf94afd727ef2259babb.zip
Bug 543747 - Add more tests
Change-Id: I87287fa270c4e21447f9de0a4cf371a79c0d0f9c Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Diffstat (limited to 'tests/org.eclipse.swt.tests.win32')
-rw-r--r--tests/org.eclipse.swt.tests.win32/ManualTests/org/eclipse/swt/tests/win32/snippets/Bug543747_JvmCrash_Msctf.java77
1 files changed, 68 insertions, 9 deletions
diff --git a/tests/org.eclipse.swt.tests.win32/ManualTests/org/eclipse/swt/tests/win32/snippets/Bug543747_JvmCrash_Msctf.java b/tests/org.eclipse.swt.tests.win32/ManualTests/org/eclipse/swt/tests/win32/snippets/Bug543747_JvmCrash_Msctf.java
index 9e5f96f168..b157caa3ad 100644
--- a/tests/org.eclipse.swt.tests.win32/ManualTests/org/eclipse/swt/tests/win32/snippets/Bug543747_JvmCrash_Msctf.java
+++ b/tests/org.eclipse.swt.tests.win32/ManualTests/org/eclipse/swt/tests/win32/snippets/Bug543747_JvmCrash_Msctf.java
@@ -19,7 +19,11 @@ import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
public class Bug543747_JvmCrash_Msctf {
- public static void reproduce526758(Shell parentShell) {
+ /**
+ * This test demonstrates a crash where destroying a Shell
+ * accesses context already freed by 'ImmDestroyContext'.
+ */
+ public static void reproduceCrash1(Shell parentShell) {
Shell tempShell = new Shell(parentShell);
// Create something to catch initial focus, so that
@@ -47,13 +51,18 @@ public class Bug543747_JvmCrash_Msctf {
msgbox.open();
}
- public static void reproduce543747(Shell parentShell) {
+ /**
+ * This test demonstrates a crash where destroying a Shell
+ * accesses context already freed by 'ImmDestroyContext'
+ * if IME-capable Control has an intermediate parent.
+ */
+ public static void reproduceCrash23(Shell parentShell, boolean focusEditOnClose) {
Shell tempShell = new Shell(parentShell);
// Create something to catch initial focus, so that
// text.setFocus() does something. This is only to
// show that .setFocus() is important.
- new Button(tempShell, SWT.PUSH);
+ Button button = new Button(tempShell, SWT.PUSH);
// This Text will cause crash.
// Text needs to have an intermediate parent for this bug.
@@ -68,6 +77,10 @@ public class Bug543747_JvmCrash_Msctf {
// .setFocus() causes it to start up.
text.setFocus();
+ // There are two slightly different crashes depending on focus
+ if (!focusEditOnClose)
+ button.setFocus();
+
// Destroying the shell triggers the bug.
tempShell.dispose();
@@ -83,6 +96,44 @@ public class Bug543747_JvmCrash_Msctf {
msgbox.open();
}
+ /**
+ * This test demonstrates a crash where destroying a Composite
+ * with Text inside it crashes, even if 'ImmDestroyContext' wasn't
+ * called yet.
+ */
+ public static void reproduceCrash4(Shell parentShell) {
+ Shell tempShell = new Shell(parentShell);
+
+ // Create something to catch initial focus, so that
+ // text.setFocus() does something. This is only to
+ // show that .setFocus() is important.
+ // new Button(tempShell, SWT.PUSH);
+
+ // This Text will cause crash.
+ // Text needs to have an intermediate parent for this bug.
+ Composite composite = new Composite(tempShell, 0);
+ Text text = new Text(composite, 0);
+
+ // Shell must be visible to prevent early return in .setFocus()
+ tempShell.setSize(10, 10);
+ tempShell.open();
+
+ // ImmAssociateContext() itself is lazy.
+ // .setFocus() causes it to start up.
+ text.setFocus();
+
+ // Destroying the composite triggers the bug.
+ composite.dispose();
+
+ // Cleanup
+ tempShell.dispose();
+
+ // JVM still alive?
+ MessageBox msgbox = new MessageBox(parentShell);
+ msgbox.setMessage("Crash didn't reproduce");
+ msgbox.open();
+ }
+
public static void main (String [] args) {
Display display = new Display ();
@@ -123,13 +174,21 @@ public class Bug543747_JvmCrash_Msctf {
"e) There's no need to uninstall Application Verifier, but you can do that if you like."
);
- final Button button526758 = new Button(shell, SWT.PUSH);
- button526758.setText("Reproduce crash 526758");
- button526758.addListener(SWT.Selection, event -> {reproduce526758(shell);});
+ final Button buttonCrash1 = new Button(shell, SWT.PUSH);
+ buttonCrash1.setText("Reproduce crash #1 - Bug 526758");
+ buttonCrash1.addListener(SWT.Selection, event -> {reproduceCrash1(shell);});
+
+ final Button buttonCrash2 = new Button(shell, SWT.PUSH);
+ buttonCrash2.setText("Reproduce crash #2 - Bug 543747 (A)");
+ buttonCrash2.addListener(SWT.Selection, event -> {reproduceCrash23(shell, true);});
+
+ final Button buttonCrash3 = new Button(shell, SWT.PUSH);
+ buttonCrash3.setText("Reproduce crash #3 - Bug 543747 (B)");
+ buttonCrash3.addListener(SWT.Selection, event -> {reproduceCrash23(shell, false);});
- final Button button543747 = new Button(shell, SWT.PUSH);
- button543747.setText("Reproduce crash 543747");
- button543747.addListener(SWT.Selection, event -> {reproduce543747(shell);});
+ final Button buttonCrash4 = new Button(shell, SWT.PUSH);
+ buttonCrash4.setText("Reproduce crash #4 - Bug 543747 (C)");
+ buttonCrash4.addListener(SWT.Selection, event -> {reproduceCrash4(shell);});
shell.pack();
shell.open();

Back to the top