Calling PAPI_Library_init twice leads to SIGSEGV

Calling PAPI_Library_init twice leads to SIGSEGV

Postby manumachu » Mon Nov 10, 2014 3:25 am

Dear PAPI Users,

I apologise if the issue that I am facing has already been discussed and addressed before.

I have installed papi-5.3.0 on my Linux UBUNTU machine (8 cores Intel(R) Xeon(R) CPU E5-1620 0 @ 3.60GHz).

I use 'rapl' component to measure power. My application which calls PAPI_Library_init and PAPI_shutdown as follows throws SIGSEGV:

Code: Select all
int main() {
     PAPI_library_init(PAPI_VER_CURRENT);
     /* Find RAPL component */
     /* Create event set */
     PAPI_start(eventSet);
     /* Execute a user function */
     /* cleanup event set */
     /* destroy event set */
     PAPI_shutdown();

[color=#FF0000]     PAPI_library_init(PAPI_VER_CURRENT);[/color] /* SIGSEGV happens here */
     /* Find RAPL component */
     /* Create event set */
     PAPI_start(eventSet);
     /* Execute a user function */
     /* cleanup event set */
     /* destroy event set */
     PAPI_shutdown();     
}


As you can see, I am calling PAPI_library_init() and then PAPI_shutdown() to free all the resources and then I call PAPI_library_init() again.

The valgrind output shows "invalid read" errors, which are reproduced below:

==26654== Invalid read of size 8
==26654== at 0x4A22CE: pfm_perf_get_event_attr_info (pfmlib_perf_event_pmu.c:736)
==26654== by 0x49EDDF: pfmlib_build_event_pattrs (pfmlib_common.c:961)
==26654== by 0x4A0529: pfm_get_event_info (pfmlib_common.c:1576)
==26654== by 0x497C21: allocate_native_event (pe_libpfm4_events.c:171)
==26654== by 0x497FE4: _pe_libpfm4_ntv_name_to_code (pe_libpfm4_events.c:816)
==26654== by 0x493079: _papi_load_preset_table (papi_preset.c:492)
==26654== by 0x4990D0: _pe_libpfm4_init (pe_libpfm4_events.c:1427)
==26654== by 0x4964AB: _pe_init_component (perf_event.c:1606)
==26654== by 0x48C37B: _papi_hwi_init_global (papi_internal.c:1705)
==26654== by 0x48A0C4: PAPI_library_init (papi.c:612)
...
==26654== Address 0x8b9a2b0 is 0 bytes after a block of size 131,072 alloc'd
==26654== at 0x4C2CE8E: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26654== by 0x4A1238: perf_table_alloc_umask (pfmlib_perf_event_pmu.c:295)
==26654== by 0x4A1640: gen_tracepoint_table (pfmlib_perf_event_pmu.c:417)
==26654== by 0x4A1896: pfm_perf_init (pfmlib_perf_event_pmu.c:490)
==26654== by 0x49E167: pfmlib_pmu_activate (pfmlib_common.c:545)
==26654== by 0x49E38E: pfmlib_init_pmus (pfmlib_common.c:626)
==26654== by 0x49E523: pfm_initialize (pfmlib_common.c:689)
==26654== by 0x4AAEB4: _papi_libpfm4_init (papi_libpfm4_events.c:105)
==26654== by 0x49648A: _pe_init_component (perf_event.c:1599)
==26654== by 0x48C37B: _papi_hwi_init_global (papi_internal.c:1705)
==26654== by 0x48A0C4: PAPI_library_init (papi.c:612)
==26654==
==26654==
==26654== Process terminating with default action of signal 11 (SIGSEGV)
==26654== Access not within mapped region at address 0x125FCAB0
==26654== at 0x4A22CE: pfm_perf_get_event_attr_info (pfmlib_perf_event_pmu.c:736)
==26654== by 0x49EDDF: pfmlib_build_event_pattrs (pfmlib_common.c:961)
==26654== by 0x4A0529: pfm_get_event_info (pfmlib_common.c:1576)
==26654== by 0x497C21: allocate_native_event (pe_libpfm4_events.c:171)
==26654== by 0x497FE4: _pe_libpfm4_ntv_name_to_code (pe_libpfm4_events.c:816)
==26654== by 0x493079: _papi_load_preset_table (papi_preset.c:492)
==26654== by 0x4990D0: _pe_libpfm4_init (pe_libpfm4_events.c:1427)
==26654== by 0x4964AB: _pe_init_component (perf_event.c:1606)
==26654== by 0x48C37B: _papi_hwi_init_global (papi_internal.c:1705)
==26654== by 0x48A0C4: PAPI_library_init (papi.c:612)

Please let me know if my use of the PAPI functions is erroneous.

Thanks a lot for your help.

Best Regards
Manumachu
manumachu
 
Posts: 3
Joined: Mon Nov 10, 2014 3:10 am

Re: Calling PAPI_Library_init twice leads to SIGSEGV

Postby jagode00 » Mon Nov 10, 2014 12:19 pm

Version 5.3.0 is almost over one year old.
Could you please try the PAPI git version and let us know if you still get the same problem?

git clone https://icl.cs.utk.edu/git/papi.git

Thanks,
Heike
jagode00
 
Posts: 41
Joined: Tue Aug 25, 2009 2:12 pm

Re: Calling PAPI_Library_init twice leads to SIGSEGV

Postby manumachu » Wed Nov 26, 2014 10:59 pm

Hi Heike,

I have tried the latest PAPI version through the 'git clone' command.

There is a problem. Please find attached the test file I used for the bug verification.

To summarize, the test file has the following function call order:

Code: Select all
PAPI_library_init
PAPI_create_eventset
PAPI_start
PAPI_stop
PAPI_cleanup_eventset
PAPI_destroy_eventset
PAPI_shutdown

PAPI_library_init
PAPI_create_eventset
PAPI_start
PAPI_stop
PAPI_cleanup_eventset
PAPI_destroy_eventset
PAPI_shutdown


When I call 'PAPI_library_init' for the second time, I get the following error:

rdmsr:pread: No such file or directory

However, if I remove 'PAPI_shutdown', I am able to run the test successfully.

Best Regards
Manumachu
manumachu
 
Posts: 3
Joined: Mon Nov 10, 2014 3:10 am


Return to Classic PAPI (read-only)

Who is online

Users browsing this forum: No registered users and 0 guests