[libcxx-commits] [PATCH] D123228: [libc++][WIP] Implement P0881R7 (std::stacktrace)

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Apr 6 09:20:05 PDT 2022


Mordante added a comment.

Nice see this being worked on!
I mainly looked at the code out of curiosity, I didn't do a review.



================
Comment at: libcxx/include/__stacktrace/basic_stacktrace.h:23
+_LIBCPP_FUNC_VIS
+void __get_stacktrace(size_t __skip, size_t __max_depth, __stacktrace_emplace_callback* __emplace_back, void* __vector);
+
----------------
Since this function is in the dylib it needs an availability macro in `<__availability>`.



================
Comment at: libcxx/src/stacktrace/stacktrace_entry.cpp:40
+  int status;
+  char* const demangeled_name = __cxxabiv1::__cxa_demangle(mangled_name.get(), nullptr, 0, &status);
+
----------------
When line 45 throws the pointer leaks.
I would suggest to do something like 
```
    // Unused; the returned pointer is used to test the conversion status.
    int __s;
    unique_ptr<char, void (*)(void*)> __demangled{abi::__cxa_demangle(__name, nullptr, 0, &__s), std::free};
```
(I wrote this for a libc++ formatting experiment.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123228/new/

https://reviews.llvm.org/D123228



More information about the libcxx-commits mailing list