Skip to content

alloc-override.c uses wrong type for std::nothrow_t argument in C++ operator new overrides #840

Closed
@sbc100

Description

@sbc100

alloc-override.c overrides operator new, etc, using C functions with C++ mangled names. e.g:

void* _ZnwmRKSt9nothrow_t(size_t n, mi_nothrow_t tag) { MI_UNUSED(tag); return mi_new_nothrow(n); }

The requires signature of this function can be seen via c++filt:

$ c++filt _ZnwmRKSt9nothrow_t
operator new(unsigned long, std::nothrow_t const&)

Note that the second argument here (and everywhere that std::nothrow_t is uses) is passed by reference, but _ZnwmRKSt9nothrow_t is passing mi_nothrow_t by value.

On most platform, especially since all the overrides simply ignore this argument, this is not an issue, but on Wasm C signatures are requires to match between compilation unit.

As it stands, under wasm64, we get a linker warning about the std::nothrow_t argument having a different width in libmimalloc compared to libc++.

See emscripten-core/emscripten#21127 for the proposed downstream fix.

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