[libcxx-commits] [PATCH] D125268: [libc++abi] Refactor exception type demangling into a separate function
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue May 10 07:14:27 PDT 2022
ldionne added inline comments.
================
Comment at: libcxxabi/src/cxa_default_handlers.cpp:64-65
static_cast<const __shim_type_info*>(exception_header->exceptionType);
-#if !defined(LIBCXXABI_NON_DEMANGLING_TERMINATE)
- // Try to get demangled name of thrown_type
- int status;
char buf[1024];
- size_t len = sizeof(buf);
- const char* name = __cxa_demangle(thrown_type->name(), buf, &len, &status);
- if (status != 0)
- name = thrown_type->name();
-#else
- const char* name = thrown_type->name();
-#endif
+ char const* name = demangle(thrown_type->name(), buf);
// If the uncaught exception can be caught with std::exception&
----------------
urnathan wrote:
> This isn't code you're changing the meaning of, but this is broken. the buffer passed to __cxa_demangle must come from malloc. If ever a thrown type demangles to more than 1024 chars, people are going to be sad.
Thank you, that is an excellent observation.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125268/new/
https://reviews.llvm.org/D125268
More information about the libcxx-commits
mailing list