Skip to content

Commit ccf81ff

Browse files
committed
[test-suite] Avoid segfault in CLAMR test on non-Linux systems
On FreeBSD, the CLAMR test immediately segfaults on startup, when it parses /proc/pid/status in the `memstats_memused()` function. This is because the parser is not very robust, and the FreeBSD /proc format is different than Linux. I expect this code to crash on anything else than Linux, but for our test purposes the memory statistics printed are not important, since nobody ever looks at the produced output. Since there is already a `MEMORY` define controlling the printing of memory statistics, only call the `memstats_memused()` function if it is explicitly enabled (which it is not, by default). Reviewed By: brad Differential Revision: https://reviews.llvm.org/D146387
1 parent 09df159 commit ccf81ff

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/clamr_cpuonly.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ int main(int argc, char **argv) {
271271
mesh->parallel_output("CPU: setup time time was",cpu_time_main_setup, 0, "s");
272272
#endif
273273

274-
long long mem_used = memstats_memused();
275274
#ifdef MEMORY
275+
long long mem_used = memstats_memused();
276276
if (mem_used > 0) {
277277
mesh->parallel_output("Memory used in startup ",mem_used, 0, "kB");
278278
mesh->parallel_output("Memory peak in startup ",memstats_mempeak(), 0, "kB");
@@ -627,8 +627,8 @@ extern "C" void do_calc(void)
627627
// Get overall program timing.
628628
double elapsed_time = cpu_timer_stop(tstart);
629629

630-
long long mem_used = memstats_memused();
631630
#ifdef MEMORY
631+
long long mem_used = memstats_memused();
632632
if (mem_used > 0) {
633633
printf("Memory used %lld kB\n",mem_used);
634634
printf("Memory peak %lld kB\n",memstats_mempeak());

0 commit comments

Comments
 (0)