Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra safe-guard to pointer allocation when a pointer is passed as an argument #1107

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ganganoaa
Copy link
Contributor

Description
This update relates to checking state of a pointer passed as an argument before reallocating it. In particular, the pointer argument, 'bc_rest_files', is passed into subroutines 'CT_register_restarts_2d', 'CT_register_restarts_3d', 'mpp_io_CT_register_restarts_2d', and 'mpp_io_CT_register_restarts_3d' but its state is unknown. In order to avoid multiple allocations without freeing, checks are added before reallocation.

Fixes #1099

How Has This Been Tested?
The update was tested with 'make check' and 'make distcheck' without any issues on OS, 'CentOS Stream 8'. The following setup was used for compiler, MPI wrapper, and required packages:

  • oneapi v2022.2
  • hdf5 v1.12.0
  • tbb v2021.6.0
  • oclfpga v2022.1.0
  • netcdf v4.8.0
  • mpi v2021.6.0 (Intel(R) MPI Library 2021.6)
  • compiler-rt v2022.1.0
  • compiler v2022.1.0

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included
  • make distcheck passes

@ganganoaa ganganoaa changed the title Added extra safe-guard to pointer allocation when a pointer is passed as an argument Add extra safe-guard to pointer allocation when a pointer is passed as an argument Feb 7, 2023
@thomas-robinson
Copy link
Member

Is this only for mpp_io?

@thomas-robinson
Copy link
Member

@uramirez8707 @mcallic2 should these routines just be removed? They are named with mpp_io at the beginning.

@ganganoaa
Copy link
Contributor Author

I don't think those routines are actually related to mpp_io.

@uramirez8707
Copy link
Contributor

The mpp_io_* subroutines are going to be #IFDEF out in #1064
They are public interfaces and may still be used by model components

@mcallic2
Copy link
Contributor

Yea, what Uriel said lol. Best not to remove anything, that is why we ifdef'd the old io out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allocated Pointers: Potential Memory Leak Issue
4 participants