Commit [04ee55] Maximize Restore History

Fix seg fault due to incorrect array size initialization

The operf_sfile.cpp:create_sfile function creates and initializes the
array of 'struct operf_sfile' objects used for writing sample data to
oprofile formatted sample files. This function creates an array of
these objects, but was incorrectly creating an array of size 'OP_MAX_COUNTER'.
Since operf can multiplex events, we aren't limited to OP_MAX_COUNTER
events to profile simultaneously, so if the user specifies more than
OP_MAX_COUNTER events, the code that accesses this array was going
off the end and sometimes seg faulting.

This patch fixes the problem by defining OP_MAX_EVENTS to be '24' and
using that as the array size. Furthermore, if the user tries to specify
more than 24 events to profile, an error message is displayed:
Number of events specified is greater than allowed maximum of <n>
and operf aborts.

Signed-off-by: Maynard Johnson <>

Maynard Johnson Maynard Johnson 2013-03-07

changed libperf_events
changed libperf_events/operf_sfile.cpp
changed libperf_events/operf_sfile.h
changed libperf_events/operf_utils.h
changed pe_profiling
changed pe_profiling/operf.cpp
libperf_events/operf_sfile.cpp Diff Switch to side-by-side view
libperf_events/operf_sfile.h Diff Switch to side-by-side view
libperf_events/operf_utils.h Diff Switch to side-by-side view
pe_profiling/operf.cpp Diff Switch to side-by-side view