Copilot commented on code in PR #13733: URL: https://github.com/apache/trafficserver/pull/13733#discussion_r4301764622
########## src/tscore/Demangle.cc: ########## @@ -0,0 +1,41 @@ +/** @file + + Readable C++ type names. + + @section license License + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#include "tscore/Demangle.h" + +#include <cstdlib> +#include <cxxabi.h> + +namespace ts +{ +std::string +demangle(std::type_info const &type) +{ + int status = 0; + char *name = abi::__cxa_demangle(type.name(), nullptr, nullptr, &status); + std::string result{status == 0 && name != nullptr ? name : type.name()}; Review Comment: All new callers invoke `ts::demangle` while already handling an exception (including `abort_on_uncaught_exception`). `__cxa_demangle` and the `std::string` construction can throw `std::bad_alloc`; if that happens, a CLI catch handler escapes, while the daemon's terminate handler recursively invokes `std::terminate`, losing the intended diagnostic/abort path. Make this diagnostic path allocation-failure-safe (for example, catch demangling failures at the call sites and fall back to `type.name()`) before using it from exception/terminate handlers. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
