<div dir="ltr"><div>> I just want to clarify that the change above just removes *one* usage of <br>
</div><div>> SafeFetch. My guess is that all other usages of SafeFetch is still <br></div><div>> affected by the issue you are seeing.</div><div><br></div><div>For whatever reason, it only crashed in ObjectMonitor::TrySpin(). Perhaps, it's just the first one that is reached.</div><div><br></div><div>Anyway, I'll check the patch and get back to you.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 12, 2024 at 2:18 PM Stefan Karlsson <<a href="mailto:stefan.karlsson@oracle.com">stefan.karlsson@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi again,<br>
<br>
I just want to clarify that the change above just removes *one* usage of <br>
SafeFetch. My guess is that all other usages of SafeFetch is still <br>
affected by the issue you are seeing.<br>
<br>
It would be interesting to see if you could verify this problem by <br>
applying this patch:<br>
<br>
diff --git a/src/hotspot/share/memory/universe.cpp <br>
b/src/hotspot/share/memory/universe.cpp<br>
index 2a3d532725f..b58c52e415b 100644<br>
--- a/src/hotspot/share/memory/universe.cpp<br>
+++ b/src/hotspot/share/memory/universe.cpp<br>
@@ -842,7 +842,14 @@ jint universe_init() {<br>
    return JNI_OK;<br>
  }<br>
<br>
+#include "runtime/safefetch.hpp"<br>
+<br>
  jint Universe::initialize_heap() {<br>
+  char* mem = os::reserve_memory(16 * K, false, mtGC);<br>
+  intptr_t value = SafeFetchN((intptr_t*)mem, 1);<br>
+<br>
+  log_info(gc)("Reserved memory read: " PTR_FORMAT " " PTR_FORMAT, <br>
p2i(mem), value);<br>
+<br>
    assert(_collectedHeap == nullptr, "Heap already created");<br>
    _collectedHeap = GCConfig::arguments()->create_heap();<br>
<br>
<br>
and running:<br>
build/<config_path>/jdk/bin/java -version<br>
<br>
This works on 14.3.1, but it would be interesting to see what happens on <br>
14.4, and if that shuts down the VM before it is printing the version <br>
string.<br>
<br>
StefanK<br>
<br>
On 2024-03-12 09:34, Stefan Karlsson wrote:<br>
> Hi Maxim,<br>
><br>
> On 2024-03-12 08:12, Maxim Kartashev wrote:<br>
>> Hello!<br>
>><br>
>> This has been recently filed as <br>
>> <a href="https://bugs.openjdk.org/browse/JDK-8327860" rel="noreferrer" target="_blank">https://bugs.openjdk.org/browse/JDK-8327860</a> but I also wanted to <br>
>> check with the community if any further info on the issue is available.<br>
>><br>
>> It looks like in some cases SafeFetch is directed to fetch something <br>
>> the OS really doesn't want it to and, instead of promoting the error <br>
>> to a signal and letting the application (JVM) deal with it, <br>
>> immediately terminates the application. All we've got is the OS crash <br>
>> report, not even the JVM's fatal error log. This looks like an <br>
>> application security precaution, which I am not at all familiar with.<br>
>><br>
>> The relevant pieces of the crash log are below. Is anybody familiar <br>
>> with "Namespace GUARD" termination reason and maybe other related <br>
>> novelties of macOS 14.4? The error was not reported before upgrading <br>
>> to 14.4<br>
><br>
> I don't have an answer for this, but a note below:<br>
><br>
>><br>
>> Thanks in advance,<br>
>><br>
>> Maxim.<br>
>><br>
>> 0 libjvm.dylib 0x1062d6ec0 _SafeFetchN_fault + 0<br>
>> 1 libjvm.dylib 0x1062331a4 ObjectMonitor::TrySpin(JavaThread*) + 408<br>
>> 2 libjvm.dylib 0x106232b44 ObjectMonitor::enter(JavaThread*) + 228<br>
>> 3 libjvm.dylib 0x10637436c ObjectSynchronizer::enter(Handle, <br>
>> BasicLock*, JavaThread*) + 392<br>
><br>
> FYI: I think that this specific call to SafeFetch was recently removed <br>
> by:<br>
> <a href="https://github.com/openjdk/jdk/commit/29397d29baac3b29083b1b5d6b2cb06e456af0c3" rel="noreferrer" target="_blank">https://github.com/openjdk/jdk/commit/29397d29baac3b29083b1b5d6b2cb06e456af0c3</a> <br>
><br>
> <a href="https://bugs.openjdk.org/browse/JDK-8320317" rel="noreferrer" target="_blank">https://bugs.openjdk.org/browse/JDK-8320317</a><br>
><br>
> Cheers,<br>
> StefanK<br>
><br>
><br>
>> ...<br>
>><br>
>> Exception Type:        EXC_BAD_ACCESS (SIGKILL)<br>
>> Exception Codes:       KERN_PROTECTION_FAILURE at 0x00000001004f4000<br>
>> Exception Codes:       0x0000000000000002, 0x00000001004f4000<br>
>><br>
>> Termination Reason:    Namespace GUARD, Code 5<br>
>><br>
>> VM Region Info: 0x1004f4000 is in 0x1004f4000-0x1004f8000;  bytes <br>
>> after start: 0  bytes before end: 16383<br>
>>       REGION TYPE                    START - END         [ VSIZE] <br>
>> PRT/MAX SHRMOD  REGION DETAIL<br>
>>       mapped file                 1004e4000-1004f4000    [ 64K] <br>
>> r--/r-- SM=COW  Object_id=fa8d88e7<br>
>> --->  VM_ALLOCATE                 1004f4000-1004f8000    [ 16K] <br>
>> ---/rwx SM=NUL<br>
>>       VM_ALLOCATE                 1004f8000-1004fc000    [ 16K] <br>
>> r--/rwx SM=PRV<br>
><br>
<br>
</blockquote></div>