BaeInpyo and I discover that under the current implementation shared memory for communication with TORCS is never deleted. This is because the only call to free_shared_mem is done in a correct scenario where the race is completed and the main event loop at real-time_simulator_basic is terminated.
This does not produce visible problems because as the TORCS and SIMULATOR processes die they release the shared memory but its instance remains. However, if the shared memory instance/declaration were to be changed problems could appear and would be hard to debug.
We propose a solution to this problem by releasing memory even if the simulator is terminated via a signal (abnormal termination)
Additionally, note that shared memory is deleted from both TORCS and the SIMULATOR, so in case of normal termination the shmctl function at the SIMULATOR will result in an error as this shared memory instance does not exist anymore.
BaeInpyo and I discover that under the current implementation shared memory for communication with TORCS is never deleted. This is because the only call to
free_shared_mem
is done in a correct scenario where the race is completed and the main event loop atreal-time_simulator_basic
is terminated.This does not produce visible problems because as the TORCS and SIMULATOR processes die they release the shared memory but its instance remains. However, if the shared memory instance/declaration were to be changed problems could appear and would be hard to debug.
We propose a solution to this problem by releasing memory even if the simulator is terminated via a signal (abnormal termination)
The following commit can be used as reference: https://github.com/BaeInpyo/CPSim_linux/commit/50614c7dd60c19f38542f4018aadceb9c2b7ff25
Additionally, note that shared memory is deleted from both TORCS and the SIMULATOR, so in case of normal termination the
shmctl
function at the SIMULATOR will result in an error as this shared memory instance does not exist anymore.