JDK-8259555 : Webkit crashes on Apple Silicon
  • Type: Bug
  • Component: javafx
  • Sub-Component: web
  • Affected Version: openjfx16
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • CPU: aarch64
  • Submitted: 2021-01-11
  • Updated: 2021-05-11
  • Resolved: 2021-04-02
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 8 Other
8u301Fixed openjfx11.0.12Fixed
Related Reports
Relates :  
Description
Steps:
* Run Ensemble
* In the Search box, type "web". Select either WebView or WebEngine
* Process crashes with SIGBUS:
```
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGBUS (0xa) at pc=0x00000001a64149cc, pid=46514, tid=771
#
# JRE version: OpenJDK Runtime Environment (11.0.10+7) (build 11.0.10+7-LTS)
# Java VM: OpenJDK 64-Bit Server VM (11.0.10+7-LTS, mixed mode, tiered, compressed oops, g1 gc, bsd-aarch64)
# Problematic frame:
# C  [libsystem_platform.dylib+0x39cc]  _platform_memmove+0x9c
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  S U M M A R Y ------------

Command Line: Ensemble8.jar

Host: Macmini9,1 arm64 1 MHz, 8 cores, 16G, Darwin 20.1.0
Time: Mon Dec 28 15:07:57 2020 MSK elapsed time: 10.600855 seconds (0d 0h 0m 10s)

---------------  T H R E A D  ---------------

Current thread (0x0000000135a4d000):  JavaThread "JavaFX Application Thread" [_thread_in_native, id=771, stack(0x000000016bbc8000,0x000000016dbc8000)]

Stack: [0x000000016bbc8000,0x000000016dbc8000],  sp=0x000000016dbc1220,  free space=32740k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libsystem_platform.dylib+0x39cc]  _platform_memmove+0x9c
C  [libjfxwebkit.dylib+0x14969b8]  JSC::LinkBuffer::linkCode(JSC::MacroAssembler&, JSC::JITCompilationEffort)+0x38
C  [libjfxwebkit.dylib+0x19fd5e4]  JSC::nativeForGenerator(JSC::VM&, JSC::ThunkFunctionType, JSC::CodeSpecializationKind, JSC::ThunkEntryType)+0x520
C  [libjfxwebkit.dylib+0x19ec0d4]  JSC::JITThunks::ctiStub(JSC::VM&, JSC::MacroAssemblerCodeRef<(WTF::PtrTag)26129> (*)(JSC::VM&))+0x88
C  [libjfxwebkit.dylib+0x19ec2f8]  JSC::JITThunks::ctiInternalFunctionCall(JSC::VM&)+0x20
C  [libjfxwebkit.dylib+0x1d5816c]  JSC::VM::VM(JSC::VM::VMType, JSC::HeapType)+0x3564
C  [libjfxwebkit.dylib+0x1d5aec4]  JSC::VM::create(JSC::HeapType)+0x28
C  [libjfxwebkit.dylib+0x6382dc]  WebCore::commonVMSlow()+0x20
C  [libjfxwebkit.dylib+0xb2d8ac]  WebCore::PageScriptDebugServer::PageScriptDebugServer(WebCore::Page&)+0x28
C  [libjfxwebkit.dylib+0xb119cc]  WebCore::InspectorController::InspectorController(WebCore::Page&, WebCore::InspectorClient*)+0x160
C  [libjfxwebkit.dylib+0xc8b7dc]  WebCore::Page::Page(WebCore::PageConfiguration&&)+0xd0
C  [libjfxwebkit.dylib+0xb3a20]  Java_com_sun_webkit_WebPage_twkCreatePage+0x3a4
```

See attached hs_err_pid46514.log


Comments
Changeset: b2f842de Author: Arun Joseph <ajoseph@openjdk.org> Date: 2021-04-02 17:55:59 +0000 URL: https://git.openjdk.java.net/jfx/commit/b2f842de
02-04-2021

The most recent WebKit update to version 610.2 -- JDK-8259635 -- has already pulled in the necessary commits. The only outstanding change that is needed is the addition of the `|| PLATFORM(JAVA) && OS(MAC_OS_X)` to the check that enables `HAVE_PTHREAD_JIT_PERMISSIONS_API`. [~peterz] Arun has a pull request out for that change, and will add you as a contributor.
02-04-2021

The crash happens in JavaScriptCore initialization code. The reason is, in Big Sur, permission to write to/execute a memory region should be explicitly set using `pthread_jit_write_protect_np()`. Currently we don't do that. Link to Apple doc page explaining the policy: https://developer.apple.com/documentation/apple_silicon/porting_just-in-time_compilers_to_apple_silicon?language=objc I've ported relevant patches from Webkit trunk, and enabled the new HAVE_PTHREAD_JIT_PERMISSIONS_API flag in Source/WTF/wtf/PlatformHave.h . The flag is enabled only for the Java port when building on Big Sur or above. Webkit changesets ported: https://trac.webkit.org/changeset/257812/webkit https://trac.webkit.org/changeset/259582/webkit https://trac.webkit.org/changeset/259711/webkit https://trac.webkit.org/changeset/262591/webkit https://trac.webkit.org/changeset/262670/webkit https://trac.webkit.org/changeset/263380/webkit https://trac.webkit.org/changeset/269396/webkit PR: https://github.com/openjdk/jfx/pull/374
11-01-2021