Questions about the trivial downcall

Cheng Jin jincheng at ca.ibm.com
Thu Jul 27 00:40:29 UTC 2023


>> Right, JNI has not much to do with this. There's different ways to upcall back into Java (JNI and FFM upcall stubs).
If so, my understanding is that both JNI and FFM upcall should crash the VM in a trivial FFM downcall, correct?

Best Regards
Cheng Jin

From: Maurizio Cimadamore <maurizio.cimadamore at oracle.com>
Sent: Wednesday, July 26, 2023 8:29 PM
To: Cheng Jin <jincheng at ca.ibm.com>; panama-dev at openjdk.org
Subject: [EXTERNAL] Re: Questions about the trivial downcall

and does not call back into Java (e. g. using an upcall stub). ß------------------------- it occurs to me that any kind of upcall should be disallowed in such case whether it is JNI or FFM, am I correct? Right, JNI has not much to do with this. 
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
    Report Suspicious  <https://us-phishalarm-ewt.proofpoint.com/EWT/v1/PjiDSg!2c-gyJS_6lP6sKYb2IHEjb2TaeBqM7xJQ9RStijLaImfla_LrFEK8T2PB5_umxDwUuL8X7BGAHosOeXRLCglJfzdYnJaiHF6gQ$>   ‌
ZjQcmQRYFpfptBannerEnd

and does not call back into Java (e.g. using an upcall stub). <--------------------------- it occurs to me that any kind of upcall should be disallowed in such case whether it is JNI or FFM, am I correct?

Right, JNI has not much to do with this. There's different ways to upcall back into Java (JNI and FFM upcall stubs).

Your question is: what happens if we do call back when we are in trivial mode.

I believe the answer is "we crash" (but not in a "nice way"), and I'm not too sure we can do much to prevent that. I believe Jorn knows more on that topic.

Maurizio

Best Regards
Cheng Jin

From: Maurizio Cimadamore <maurizio.cimadamore at oracle.com><mailto:maurizio.cimadamore at oracle.com>
Sent: Wednesday, July 26, 2023 7:44 PM
To: Cheng Jin <jincheng at ca.ibm.com><mailto:jincheng at ca.ibm.com>; panama-dev at openjdk.org<mailto:panama-dev at openjdk.org>
Subject: [EXTERNAL] Re: Questions about the trivial downcall

Hi, a trivial downcall is supposed to target a native function that (a) terminates quickly (so as not to block the GC for too long) and (b) does not upcall into Java. So, no, a trivial downcall cannot trigger upcalls (I don't think we detect
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
    Report Suspicious  <https://us-phishalarm-ewt.proofpoint.com/EWT/v1/PjiDSg!2c-r455VanMQ2qYReaGl7Z4QRx46ATMxAjK9nbXsj13QlLeimn0PtcIAb-U80cJ-A34Q8dYfoQ6JN5nMYOpBz-Hn3cuAGTZLJQ$>   ‌
ZjQcmQRYFpfptBannerEnd

Hi,
a trivial downcall is supposed to target a native function that (a) terminates quickly (so as not to block the GC for too long) and (b) does not upcall into Java.

So, no, a trivial downcall cannot trigger upcalls (I don't think we detect this, I believe the JVM just crashes if you do).

Also I notice that you speak of "JNI" upcall. Is that what you really mean - e.g. a trivial FFM downcall making an upcall using JNI? In general, I think it's a bit hard for downcalls to do anything that has to do with JNI because the invoked native function is not passed a JNIEnv - FFM really just bridges the Java code with the native library function you want to call, nothing more. (I suppose that function could get its hands on the VM using the JNI attach API, but I feel that's a different question from what you were asking?).

Maurizio
On 26/07/2023 22:23, Cheng Jin wrote:
Hi there,

I’ve got a couple of questions about the behavior of a trivial downcall (with isTrivial specified).

Is a FFI downcall able to trigger a JNI upcall ?
If so, should a JNI upcall should be captured in this trivial downcall?

Best Regards
Cheng Jin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20230727/c0addb10/attachment-0001.htm>


More information about the panama-dev mailing list