vmware-archive / go-pmem-transaction

Golang library for using persistent memory
Other
29 stars 5 forks source link

Functions accessing appData datastructure are not thread-safe #13

Closed jerrinsg closed 5 years ago

jerrinsg commented 5 years ago

Functions such as Get(), GetSlice(), Delete() that uses the appData data-structure are currently not thread-safe. These functions call exists() to identify if a named object already exists. It then uses the index returned by exists() to manipulate that named object. But we grab the lock protecting the map only within exists(). Once exists() returns, we cannot be sure that the returned index still points to the object we want as some other goroutine could have modified the map in the mean time. Therefore the lock protecting the map should be acquired before calling exists() and released only after the operation on that object is completed.

jerrinsg commented 5 years ago

Fixed in #14