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

@@ -9,7 +9,7 @@ from enum import Enum
from colorama import Fore, Style, init
from datetime import timedelta
from slsdet import Detector, detectorSettings, burstMode
from slsdet import Detector, Ctb, detectorSettings, burstMode
from slsdet.defines import DEFAULT_TCP_RX_PORTNO, DEFAULT_UDP_DST_PORTNO
SERVER_START_PORTNO=1900
@@ -167,9 +167,12 @@ def startDetectorVirtualServer(name :str, num_mods, fp):
time.sleep(3)
def connectToVirtualServers(name, num_mods):
def connectToVirtualServers(name, num_mods, ctb_object=False):
try:
d = Detector()
if ctb_object:
d = Ctb()
else:
d = Detector()
except Exception as e:
raise RuntimeException(f'Could not create Detector object for {name}. Error: {str(e)}') from e