[foreign-memaccess] RFR: Fix concurrent MemoryScope.close() or MemoryScope.dup() race

Peter Levart plevart at openjdk.java.net
Tue May 12 05:17:08 UTC 2020


In case a MemorySegment is not confined to an "owner" thread, it is possible to call close() or
withOwnerThread(newThread) on it from multiple threads concurrently and such calls are not screened for thread
confinement but just forwarded to MemoryScope.close() and .dup(). It is therefore vital that close() and dup() are made
atomic so that cleanupAction is executed just once.

-------------

Commit messages:
 - Fix concurrent scope.close() or scope.dup() race (relevant in unconfined segments)

Changes: https://git.openjdk.java.net/panama-foreign/pull/160/files
 Webrev: https://webrevs.openjdk.java.net/panama-foreign/160/webrev.00
  Stats: 18 lines in 1 file changed: 13 ins; 3 del; 2 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/160.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/160/head:pull/160

PR: https://git.openjdk.java.net/panama-foreign/pull/160


More information about the panama-dev mailing list