[foreign-memaccess] on shared segments

Jorn Vernee jorn.vernee at oracle.com
Fri Sep 27 11:59:44 UTC 2019


On 27/09/2019 13:54, Maurizio Cimadamore wrote:
>
> On 27/09/2019 11:46, Jorn Vernee wrote:
>> Reading through the code, there is one caveat that doesn't seem to be 
>> addressed yet; only the owning thread can call asShared() or 
>> asConfined() (not being checked currently), and, at least for 
>> asConfined(), I think the owning thread has to submit to a full fence 
>> before transferring the segment to make sure no accesses 'spill over' 
>> into the new state. 
>
> Right, I should add the checks.
>
> Not sure about the fence - I thought about that. We are creating a 
> _new_ object, and invalidating an old one. Only the old thread has 
> access to the old one, so it cannot possibly perform access on the old 
> segment AFTER it is closed. And, the new thread cannot access the 
> segment before the old thread is actually inside the transfer code 
> (which means he's done with the segment already).
>
> If we were modifying the ownership in place, I'd agree a fence would 
> be in order - but here?

To sketch the scenario I'm thinking of: Let's say ownership is 
transferred from thread A to thread B.

* A writes to the memory segment, but this ends up in the core's cache, 
due to no memory fencing.
* A transfers ownership to B
* B closes the segment, freeing the memory
* The cache of thread A is flushed to memory (BOOM)

Jorn

> Maurizio
>


More information about the panama-dev mailing list