python accessing freed shared memory object (#1253)

* added a 'isValid' member in shared memory (also updated shm version) with default true, any access to shared memory() checks also for validity. any free will set this to false and then unmap shm. Any access to shm will then check validity in python.

* fixed tests for shm

* added tests in python as well

---------

Co-authored-by: Alice <alice.mazzoleni@psi.ch>
This commit is contained in:
2025-08-05 11:26:49 +02:00
committed by GitHub
parent f714aa22c5
commit f594826e95
11 changed files with 258 additions and 40 deletions

View File

@@ -112,4 +112,12 @@ struct Conjunction<B1, Bn...>
template <typename T, typename... Ts>
using AllSame =
typename std::enable_if<Conjunction<std::is_same<T, Ts>...>::value>::type;
// Trait to detect if T has a bool member named 'isValid'
template <typename, typename = std::void_t<>>
struct has_bool_isValid : std::false_type {};
template <typename T>
struct has_bool_isValid<T, std::void_t<decltype(std::declval<T>().isValid)>>
: std::is_same<decltype(std::declval<T>().isValid), bool> {};
} // namespace sls