I am working with a test case that uses user-defined events.
When running mpi2prv, a call to malloc segfaults, giving the following error message:malloc(): invalid size (unsorted).
The problem stems from the Labels_loadSYMfilefunction in paraver/labels.c:785 (Extrae v4.0.4, altough previous versions have the same issue).
There,strcpy(evt_value->label, value_description) is used to copy the event description into the event_value struct.
However, the maximum size of value_description is 1024, while evt_value->label is only 256 bytes long (defined by VALUE_LBL in labels.h).
Thus, if the read value_description is longer then 256 characters, strcpy will overflow, causing a segfault when trying to allocate the next event.
I suggest the following fix:
Check if the size of value_description is bigger than VALUE_LBL and print a warning if this is the case.
Truncate the event description by using strncpy(evt_value->label, value_description, VALUE_LBL)
This fixes the issue for me.
If this solution sounds reasonable to you, I can submit a pull request.
I am working with a test case that uses user-defined events. When running
mpi2prv
, a call to malloc segfaults, giving the following error message:malloc(): invalid size (unsorted)
.The problem stems from the
Labels_loadSYMfile
function inparaver/labels.c:785
(Extrae v4.0.4, altough previous versions have the same issue). There,strcpy(evt_value->label, value_description)
is used to copy the event description into theevent_value
struct. However, the maximum size ofvalue_description
is 1024, whileevt_value->label
is only 256 bytes long (defined byVALUE_LBL
in labels.h). Thus, if the readvalue_description
is longer then 256 characters,strcpy
will overflow, causing a segfault when trying to allocate the next event.I suggest the following fix:
value_description
is bigger thanVALUE_LBL
and print a warning if this is the case.strncpy(evt_value->label, value_description, VALUE_LBL)
This fixes the issue for me.If this solution sounds reasonable to you, I can submit a pull request.