[foreign] RFR: 8229857: scope inference on pointer to pointer is not friendly
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Wed Aug 28 17:23:18 UTC 2019
> That said, I think I'd like to learn more about the problem you faced,
> with some real code. The idea of scope inference is really tied to how
> close/merge work - and the fact that the runtime checks for the
> ancestor relationship when you store a pointer into another memory
> region (to check that the liveness range of the stored pointer
> outlives the containing pointer).
>
I see such an example here:
https://bugs.openjdk.java.net/browse/JDK-8229857
thanks for taking the time to write such a detailed issue.
So, from what I see the problem here is that you create a 'local' array
which contains some values that should be made available more globally.
In other words, the program is not behaving according to the desired
ownership model. The ownership model is strict but also prevents
mistakes. So it's a constant trade off.
In this case I see two options:
1) use a global scope for the allocation of the temp array
2) keep using a local scope, but then copy the contents to pointers that
are allocated outside
In other words, now that I look more closely at the problem you are
trying to solve, it's not like scope inference is misbehaving and need
to be fixed - you are essentially saying: I don't need protection (at
least in case of pointers created in a native lib - although that
automatically extends to pointers generated from struct reads), I just
want pointers to be freely assignable.
Do we agree on the description of the issue here? Then we can talk on
how to fix it.
Maurizio
More information about the panama-dev
mailing list