Skip to content

Fix SEGFAULT in BenchmarkInSitu on exit

Kenneth Moreland requested to merge kmorel/vtk-m:benchmarkinsitu-segfault into master

On some devices, we are observing a SEGFAULT crash in BenchmarkInSitu when the program exits. This is likely because the benchmark creates some global DataSet variables that are constructed before VTK-m is initialized and are therefore destroyed after VTK-m (and its devices) are finalized. The crash happens when the DataSet attempts to free the memory on the device that it allocated, but the device is no longer there to be deleted.

Fix the problem by wrapping these global variables as static variables in functions. This will defer the construction of the global variables to when the function is called. C++ specifies that global objects are destroyed in the reverse order in which they are constructed. Thus, if we defer the construction of the benchmark's objects until after the construction of internal device objects, the data will be destroyed before the device is finalized.

Fixes #712 (closed)

Merge request reports