Skip to content

Commit

Permalink
Enable write permission before writing into CodeCache segment
Browse files Browse the repository at this point in the history
`allocateVirtualMemorySegmentInListInternal` has been changed to
write NULL into the code cache segment in eclipse-openj9#18212. The change does not
include `omrthread_jit_write_protect_disable` and `omrthread_jit_write_protect_enable`
calls before and after writing to the memory, which results
in the crash on Apple Silicon Mac.
This commit inserts `omrthread_jit_write_protect_disable` and
`omrthread_jit_write_protect_enable` appropriately.

Signed-off-by: Akira Saitoh <[email protected]>
  • Loading branch information
Akira Saitoh committed Oct 5, 2023
1 parent 8abe35a commit 6983726
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions runtime/vm/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,10 @@ static J9MemorySegment * allocateVirtualMemorySegmentInListInternal(J9JavaVM *ja
/* For CodeCache segments the JIT will later write a TR::CodeCache structure pointer at the begining of the segment.
* Until then, make sure that a potential reader sees a NULL pointer.
*/
omrthread_jit_write_protect_disable();
*((UDATA**)allocatedBase) = NULL;
issueWriteBarrier();
omrthread_jit_write_protect_enable();
}
segment->baseAddress = allocatedBase;
segment->heapBase = allocatedBase;
Expand Down

0 comments on commit 6983726

Please sign in to comment.