Hello, my name is Pintaudi Giorgio and I am a Ph.D. student at Yokohama National University (T2K/WAGASCI experiment).
In the last few days, I was struggling with what I suspect is a little bug of MIDAS. I think that I have found a solution to the bug and I would like you to review it.
The problem is that I was always getting a segmentation fault error when using the odb.c/strcomb function (I am developing the MIDAS interface for our experiment). The crashes never occurred the first time that the function was called, but always the n-th time where n was always the same. The error message was quite cryptic:
mremap_chunk: Assertion `((size + offset) & (GLRO (dl_pagesize) - 1)) == 0' failed. Aborted.
At first, I thought that to solve the error, it would be enough to free the memory allocated in the heap by the malloc/realloc call in the strcomb function. But that didn't work either and I got another error instead when trying to free said memory:
free(): invalid pointer
I ultimately solved the error by deleting the "static" modifier at odb.c:499
static char *str = NULL;->
char *str = NULL;
The advantage of this solution is, of course, to remove the error and avoid the somewhat frowned upon practice of using static variables inside of a function.
- The disadvantage is that the developer now has to be manually free the memory allocated in the strcomb function to avoid memory leaks.
If you need further info, please let me know. Best regards Giorgio