chrxh/alien

SimulationCudaFacade tries to double-free CUDA alocations

Closed this issue · 1 comments

cudaDeviceReset() destroys all memory allocations on the device (among other things).

~SimulationCudaFacade() calls cudaDeviceReset() at the end of its destructor, meaning that the subsequent destruction of some of its members (such as EditKernelsLauncher) ends up trying to cudaFree these allocations after they were already freed by cudaDeviceReset. Fishy.

The program gets away with this by ignoring the return codes, but that's perhaps a bit dubious. A bit of refactoring of the object lifecycles might be called for (as well as not ignoring cuda return codes).

(I tripped over this while fiddling with something else using SCALE's exception mode, which found this unrelated problem :P ).

chrxh commented

Thanks for pointing out this error! I have just corrected it (and added a check).