minimum example already has memory-leaks

Issue #49 new
Thomas Pointhuber created an issue

example program

#include <papi.h>

int main(int argv, char **argc) {
    PAPI_library_init(PAPI_VER_CURRENT);
    PAPI_shutdown();
}

compilation

clang -g -fsanitize=address papi_test_memory.c -o papi_memory -lpapi

execution result:

=================================================================
==8743==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4443 byte(s) in 47 object(s) allocated from:
    #0 0x5596b4e37c91 in malloc (papi_memory+0xe0c91)
    #1 0x7f80d3321f36 in pfmlib_build_fstr ./papi/src/libpfm4/lib/pfmlib_common.c:867:10
    #2 0x7f80d33283d8 in pfmlib_perf_event_encode ./papi/src/libpfm4/lib/pfmlib_perf_event.c:333:8
    #3 0x7f80d33238cc in pfm_get_os_event_encoding ./papi/src/libpfm4/lib/pfmlib_common.c:1614:9
    #4 0x7f80d46ad121 in allocate_native_event ./papi/src/components/perf_event/pe_libpfm4_events.c:193:8

SUMMARY: AddressSanitizer: 4443 byte(s) leaked in 47 allocation(s).

Comments (6)

  1. Jiali Li

    Hi Thomas,

    Could you please provide more information regarding this issue?

    What version of PAPI are you using and how do you install PAPI? What component are you using?

    I installed the latest version of PAPI with the default configuration and installation, there are two components installed: perf_event_uncore and perf_event, but only perf_event is active in my case. I reproduced the example code with the same compiling options, while I didn't receive the same memory leak message as above.

    Could you please try to proceed the example with the latest version of PAPI?

    Thank you.

    Jiali

  2. Jiali Li

    In order to get more information about this issue, I build the example code in the normal method and ran with Valgrind. I found that these leaked bytes come from the initialization functions of some components. It seems that PAPI_shutdown() did not proceed, which was supposed to free allocated memory from PAPI_library_init().

    Could you please try this:

    Configure PAPI with PAPI debugger enabled:

    % cd src/

    % ./configure --prefix=SOME_PATH --with-debug=yes

    Build with specified PAPI debugger:

    % export PAPI_DEBUG=API

    % make

    Then rebuild the example code, if you build the example code properly you could see the PAPI debugger message like this:

    API:papi.c:PAPI_shutdown:4463:76881 Entry:

  3. Log in to comment