RFR: 8265292: [macos_aarch64] java/foreign/TestDowncall.java crashes with SIGBUS [v2]
Anton Kozlov
akozlov at openjdk.java.net
Tue May 11 16:02:53 UTC 2021
On Sun, 9 May 2021 09:01:39 GMT, Andrew Haley <aph at openjdk.org> wrote:
>> src/hotspot/share/prims/universalNativeInvoker.cpp line 35:
>>
>>> 33: void ProgrammableInvoker::invoke_native(Stub stub, address buff, JavaThread* thread) {
>>> 34: ThreadToNativeFromVM ttnfvm(thread);
>>> 35: MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXExec, thread));
>>
>> I think we need a comment here, not just in the bug report. if this confused you, it'll surely be enough to confuse a maintainer. Some think like this, perhaps?
>>
>> `"We need WXExec because we are about to call a generated stub. But we need to switch to WXExec only after JavaThread state change. The thread state change may trigger a safepoint, that would need to do bookkeeping in the codecache. See JDK-8265292."`
>>
>> I'm also wondering if it would be better to enable writes in the methods that actually write to the nmethod, WDYT?
>
> And incidentally, this seems to be rather error prone. Wouldn't it be simpler to check W^X status in all of the nmethod accessors, and change it when actually required, rather than hoping that it's already in the correct state?
Thanks, I've added the comment here, and also one near VM entries. I would like to avoid enabling write near writing itself. There are too many such places, and either we'll cover a rather large part of hotspot with them (with trial and fix like here, also having overhead from going back and forth), or we'll start clustering them in bigger write-contexts. The current approach is to have the largest write-context possible: the whole JVM should be able to write. Therefore, the bug is not that we didn't get to WXWrite when we are trying to write, the bug is that we were not in the right state.
Also to @dholmes-ora. Sorry for failing to provide a clear principle in the first place. I really assumed that we were on the same page until reviews of JDK-8262896. Since then I'm preparing a kind of doc, although it's going hard. Thank you for still asking questions :) I'm going to include discussed topics into that doc.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3921
More information about the hotspot-dev
mailing list