#1519: Parameter parser leaks memory --------------------+------------------------------------------------------- Reporter: rhaas | Owner: Type: defect | Status: new Priority: minor | Milestone: Component: Cactus | Version: development version Keywords: | --------------------+------------------------------------------------------- The function cctk_PirahaParser in src/piraha/Call.cc wraps each argument to its set_function (points to CCTKi_SetParameter) in a strdup (with the exception of ActiveThorns). This leads to a memory leak since CTKi_SetParameter does not free() them. To test, run a minimal parfile {{{ Cactus::cctk_itlast = 42 }}} with an executable from an empty thornlist through valgrind: {{{ valgrind --log-file=valgrind.log --leak-check=full --tool=memcheck cactus_null answer.par }}} and you will find eg {{{ ==27121== 20 bytes in 1 blocks are definitely lost in loss record 297 of 1,362 ==27121== at 0x4C2935B: malloc (vg_replace_malloc.c:270) ==27121== by 0x6249D91: strdup (strdup.c:42) ==27121== by 0x43D1C1: cctk_PirahaParser (Call.cc:875) ==27121== by 0x419855: CCTKi_ProcessParameterDatabase (ProcessParameterDatabase.c:158) ==27121== by 0x416760: CCTKi_InitialiseCactus (InitialiseCactus.c:101) ==27121== by 0x415FFD: main (flesh.cc:64) }}}
The attached patch fixes this. There is still some memory leakage (couple hundred bytes that seem to be due to the flesh and persist even when the old parser is reactivated).
#1519: Parameter parser leaks memory ---------------------+------------------------------------------------------ Reporter: rhaas | Owner: Type: defect | Status: review Priority: minor | Milestone: Component: Cactus | Version: development version Resolution: | Keywords: ---------------------+------------------------------------------------------ Changes (by rhaas):
* status: new => review
#1519: Parameter parser leaks memory ---------------------+------------------------------------------------------ Reporter: rhaas | Owner: sbrandt Type: defect | Status: review Priority: minor | Milestone: Component: Cactus | Version: development version Resolution: | Keywords: ---------------------+------------------------------------------------------ Changes (by knarf):
* owner: => sbrandt
Comment:
Looks ok to me, but I want Steve to have the last word.
#1519: Parameter parser leaks memory ---------------------+------------------------------------------------------ Reporter: rhaas | Owner: sbrandt Type: defect | Status: reviewed_ok Priority: minor | Milestone: Component: Cactus | Version: development version Resolution: | Keywords: ---------------------+------------------------------------------------------ Changes (by sbrandt):
* status: review => reviewed_ok
Comment:
I agree. I can't remember why I thought the strdup()'s were necessary, but the seem to not be needed. Please apply.
#1519: Parameter parser leaks memory ---------------------+------------------------------------------------------ Reporter: rhaas | Owner: sbrandt Type: defect | Status: closed Priority: minor | Milestone: Component: Cactus | Version: development version Resolution: fixed | Keywords: ---------------------+------------------------------------------------------ Changes (by sbrandt):
* status: reviewed_ok => closed * resolution: => fixed
Comment:
Fixed in commit 5067
trac@lists.einsteintoolkit.org