Bug 576146

Summary: [Browser][Edge] vm crash after executing BrowserFunction
Product: [Eclipse Project] Platform Reporter: Flavio Donze <flavio.donze>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: kentxu2007, nikita, niraj.modi
Version: 4.21   
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
Whiteboard:
Bug Depends on:    
Bug Blocks: 575660    
Attachments:
Description Flags
demo project containing the code to crash
none
crash dump file none

Description Flavio Donze CLA 2021-09-21 08:15:43 EDT
Created attachment 287177 [details]
demo project containing the code to crash

Switching a RCP application to use Edge (-Dorg.eclipse.swt.browser.DefaultType=edge), the vm crashes executing the following code:

	Button runButton = new Button(parent, SWT.PUSH);
	runButton.setText("open");
	runButton.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			Shell shell = new Shell(Display.getDefault().getActiveShell(), SWT.CLOSE);
			shell.setLayout(new FillLayout(SWT.HORIZONTAL));

			Browser browser = new Browser(shell, SWT.NONE);
			browser.setText("<a href=\"javascript:jsTest();\">run</a>");
			new BrowserFunction(browser, "jsTest") {
				@Override
				public Object function(Object[] arguments) {
					shell.close();
					return null;
				}
			};
			shell.open();
		}
	});

Attached is a demo project based on the "RCP 3.x application with a view" template. 
Using a Browser with BrowserFunction, after clicking on the button "open" and "run" in the browser-shell the vm crashes with the following log:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000000000000, pid=9136, tid=28176
#
# JRE version: OpenJDK Runtime Environment Zulu17.28+13-CA (17.0+35) (build 17+35-LTS)
# Java VM: OpenJDK 64-Bit Server VM Zulu17.28+13-CA (17+35-LTS, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64)
# Problematic frame:
# C  0x0000000000000000
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# D:\dev\software\eclipse\hs_err_pid9136.log
#

hs_err_pid9136.log is attached to this issue.


Environment:
Eclipse 2021-09 (4.21)
Windows 10 Pro for Workstations: 21H1
Java jdk17.0.0
Comment 1 Flavio Donze CLA 2021-09-21 08:16:28 EDT
Created attachment 287178 [details]
crash dump file
Comment 2 Kent Xu CLA 2022-01-02 12:56:47 EST
I have run into this problem too with Edge browser. One possible workaround is to invoke "close" in an async task instead of calling it directly.