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

Refactor NRT_Reallocate #536

Open
guilhermeleobas opened this issue Mar 22, 2023 · 0 comments
Open

Refactor NRT_Reallocate #536

guilhermeleobas opened this issue Mar 22, 2023 · 0 comments

Comments

@guilhermeleobas
Copy link
Contributor

guilhermeleobas commented Mar 22, 2023

You can use malloc_usable_size for determining the size of the malloc-allocated buffer. It would be Linux specific function though, see https://stackoverflow.com/questions/1281686/determine-size-of-dynamically-allocated-memory-in-c for Windows and Mac equivalents. Recall, heavydb can be built on Linux as well as on Windows.

It would be preferable to keep the original realloc API. Could you create an issue about this and emit an (only-once) warning in define_NRT_Reallocate call about the current behavior with a reference to the issue?

Originally posted by @pearu in #531 (comment)

The Numba Runtime offers a memory reallocation function called NRT_Reallocate, which internally utilizes the realloc function. However, using this function in HeavyDB can lead to issues because realloc may free the old buffer while copying memory, resulting in a double-free corruption that the HeavyDB server will subsequently try to free.

@guilhermeleobas guilhermeleobas changed the title You can use malloc_usable_size for determining the size of the malloc-allocated buffer. It would be Linux specific function though, see https://stackoverflow.com/questions/1281686/determine-size-of-dynamically-allocated-memory-in-c for Windows and Mac equivalents. Recall, heavydb can be built on Linux as well as on Windows. Refactor NRT_Reallocate Mar 22, 2023
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

No branches or pull requests

1 participant