BYU-PCCL / holodeck

High Fidelity Simulator for Reinforcement Learning and Robotics Research.
https://holodeck.cs.byu.edu
MIT License
574 stars 42 forks source link

Potential memory region size mismatch #273

Open jaydenmilne opened 5 years ago

jaydenmilne commented 5 years ago

Describe the bug There was a bug that I fixed that involved mapping memory regions of a certain size (BYU-PCCL/holodeck-engine#175). The code would try and create the shared memory file, but if it already existed, it would just use the existing one (CreateFileMapping). Then it would try and map that file to a memory region of a fixed size (MapViewOfFile). That second call would occasionally fail because the size of the file mapping and the size passed into MapViewOfFile differed apparently (I couldn't verify this - I couldn't find a way to see how large a CreateFileMapping was if it was already created)

The fix was to change the MapViewOfFile call to not specify a size (0 as the last parameter) and use the size it already was. This appears to work, but doesn't explain why the sizes didn't match (the Python code had already created the memory region)

To Reproduce Look in the log for this message

HolodeckSharedMemory:: Unable to create MemFile! The path %s already exists. Hopefully it is the correct size...

Expected behavior The memory regions should be the same size, and we should be able to pass the size of the memory into MapViewOfFile

vinhowe commented 3 years ago

This really looks like it could be fixed in https://github.com/BYU-PCCL/holodeck-engine/pull/220.