Skip to content

Refactor NRT_Reallocate #536

@guilhermeleobas

Description

@guilhermeleobas

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions