Fix multiple memory leaks and issues#806
Merged
dmitry-kabanov merged 45 commits intoMaRDI4NFDI:mainfrom Jul 16, 2025
Merged
Conversation
…anitizers If a memory leak occurs inside a dynamically loaded implementation, unloaded the implementation via `dlclose` prevents AddressSanitizer from reporting correct stack trace.
…izers AddressSanitizer does not work with embedded Python and Julia.
…f_util_free is requested Such situation can indicate a real bug or that `oif_util_free` is invoked on memory that was allocated, e.g., via `malloc` instead of `oif_util_malloc`, hence, the global number of memory allocations was not increased properly.
…ctly count allocations
…nt memory properly
Not only loading the functions `setindex!` and `delete!` on each `load_impl` is wasteful, but also there was a bug with recreating the global variable `refs_` each time, which then led sometimes to segmentation faults because we try to delete variables from the references dictionary that are not there anymore, because they were in the lost dictionary.
The OIF_FLAG_PRINT_DEBUG_VERBOSE_INFO should be used to decided if verbose debug information should be printed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MaRDI Pull Request
This PR was started simply to add destructors to C implementations, so that they can clean allocated memory. However, the actual work done here is larger in focus because much more memory issues were solved.
Changes:
NALLOCS_inutil.cwith new functionsoif_util_malloc_andoif_util_free_liboif_util.sofails in the destructor, ifNALLOCS_ != 0oif_util_malloc_verbose,oif_util_free_verboseto print verbose debug informationoif_util_malloc,oif_util_freethat actually inject debug information (file/function name, line number)oif_util_str_duplicatewith the corresponding macro that injects debug information_verboseand_(non-verbose) variants of the formeroif_util_str_duplicatelibjulia)oif_INTERFACE_free(if it exists) so that C implementations can release allocated memoryload_implthat sometimes led to segmentation fault due to an attempt to removeselfvariables for implementations when they were already garbage-collected