Issues with src/components/sysdetect/shm.c memory calloc/free when HAVE_MPI is undefined
Issue #123
resolved
I was looking through the coverity results for papi from the git repository. One of the issue reported was:
Error: BAD_FREE (CWE-590): [#def5]
papi-6.0.0/src/components/sysdetect/shm.c:323: address_free: "free" frees address of "local_mem[shm_handle]".
# 321| shm_free( int shm_handle )
# 322| {
# 323|-> free(&local_mem[shm_handle]);
# 324| return 0;
# 325| }
Noticed that there are basically two different sets of functions in shm.c and which one is used is dependent on HAVE_MPI. In this case the code was compiled without MPI support. There seems to be some confusion in the code how local_mem should be handled. Should shm_free, shm_put, and shm_get just ignore shm_handle as an index like shm_alloc just always using 0 for shm_handle?
Comments (2)
-
-
- changed status to resolved
Resolved by https://bitbucket.org/icl/papi/pull-requests/387
- Log in to comment
The reason there are two sets of call is that without MPI any call to
she_put
, for example, will still work as if MPI_COMM_SELF was used internally byshm.c
. That code (shared memory functionality) might actually go away entirely.