-
Notifications
You must be signed in to change notification settings - Fork 220
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
[OTHER]: project using nanobind crashes because nanobind demangles strings returned by typeid() #946
Comments
I have never heard of such behavior. Is it documented somewhere? |
Addendum: I suppose this is some FreeBSD-specific behavior? |
No, this is clang behavior. |
I can only repeat: I have never ever heard of such behavior. If you do have a link explaining that one has to manipulate the typeid string, then could you please post it? nanobind is used by a large number of projects and platforms, and this issue has never come up before, so something seems fishy here. |
The leading I think it would be reasonable for nanobind to compromise on something like "check for nullptr and use the mangled name if it can't be demangled". I don't think adding the leading |
17.7.3 Class type_info as in N4950: "The names, encoding rule, and collating sequence for types are all unspecified and may differ between programs." So any constraint making uniformity is more likely from ABI rules or such, rather than from the likes of the language standard. Also: "const char* name() const noexcept Returns: An implementation-defined NTBS. Remarks: The message may be a null-terminated multibyte string (16.3.3.3.4.3), suitable for conversion and display as a string (23.4, 30.4.2.5)." Also: cppreference notes that "Some implementations (such as MSVC, IBM, Oracle) produce a human-readable type name". |
At a related FreeBSD bugzilla entry, the following comment was added about another type of ABI handling of this subject area: --- Comment . . . from David Chisnall <. . .> --- |
Please don't use.
The python bindings of the proxsuite project crashes at the runtime with this stack:
The immediate cause of this crash is that
abi::__cxa_demangle()
returned nullptr on the string "N9proxsuite6linalg3veg3VecIdNS1_3mem11SystemAllocELNS3_13DtorAvailableE2ELNS3_13CopyAvailableE2EEE".The name() member of std::type_info returns an implementation-defined string
signifying the type. The standard says you cannot count on any particular
interpretation of this string, but in practice it usually contains a mangled
version of the name.
In this particular case, you should add "_Z" to the front of the string, before
demangling.
nanobind-2.4.0
Python-3.11
clang-19
FreeBSD 14.2
The text was updated successfully, but these errors were encountered: