Skip to content

C API doesn't let you tell the difference between too small buffer and non-Rust symbol #68

@VorpalBlade

Description

@VorpalBlade

// Demangles symbol given in `mangled` argument into `out` buffer
//
// Returns 0 if `mangled` is not Rust symbol or if `out` buffer is too small
// Returns 1 otherwise
int rustc_demangle(const char *mangled, char *out, size_t out_size);
shows that the same return code is used for both "not a rust symbol" and "too small buffer" in the C API. This is very unfortunate, as it makes it impossible to tell these cases apart.

This causes KDAB/hotspot#611 where hotspot will not demangle some long symbol names correctly. Consider making a breaking change (or adding an alternative function) whereby it is possible to tell these cases apart. Best would be if it would report how large the buffer would need to be.

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