Avoid segfault on exit(...)

Avoids segfault by not freeing the internal structure handling memory
allocations. When the process ends, the OS should reclaim all memory,
even if it isn't free'd during process execution.
This commit is contained in:
Stephen Seo 2024-11-12 16:32:23 +09:00
parent 33d3adba3f
commit 293b18e4bf

View file

@ -217,9 +217,12 @@ namespace SC_AM_Internal {
void exit_handler_stats() {
if (SC_AM_Internal::stats != nullptr) {
SC_AM_Internal::stats->print_status();
using SCS_AM_INTERNAL_Stats = SC_AM_Internal::Stats;
SC_AM_Internal::stats->~SCS_AM_INTERNAL_Stats();
SC_AM_Internal::stats = nullptr;
// Avoids segfault when program calls `exit(...)`. OS should reclaim memory
// when the process ends even if it isn't free'd here.
//using SCS_AM_INTERNAL_Stats = SC_AM_Internal::Stats;
//SC_AM_Internal::stats->~SCS_AM_INTERNAL_Stats();
//SC_AM_Internal::stats = nullptr;
}
}