未验证 提交 23439b16 编写于 作者: C Chen Weihang 提交者: GitHub

show cpp stack when catch signal (#28415)

上级 3c95acc3
......@@ -287,7 +287,7 @@ void SignalHandle(const char *data, int size) {
// NOTE2: we only deal with the time info ane signal info,
// the stack trace will generated by paddle self
if (StartsWith(data, "*** Aborted at")) {
*signal_msg_dunmer_ptr << " [TimeInfo: " << std::string(data, size - 1)
*signal_msg_dunmer_ptr << "\n [TimeInfo: " << std::string(data, size - 1)
<< "]\n";
} else if (StartsWith(data, "***")) {
std::string signal_info(data, size - 1);
......@@ -295,14 +295,19 @@ void SignalHandle(const char *data, int size) {
size_t start_pos = signal_info.rfind(useless_substr);
signal_info.replace(start_pos, useless_substr.length(), "");
*signal_msg_dunmer_ptr << " [SignalInfo: " << signal_info << "]\n";
// NOTE3: Here does not throw an exception,
// NOTE3: Final singal error message print.
// Here does not throw an exception,
// otherwise it will casue "terminate called recursively"
auto exp = platform::EnforceNotMet(
platform::errors::Fatal(
"A serious error (%s) is detected by the operating system.",
ParseSignalErrorString(signal_info)),
__FILE__, __LINE__);
std::cout << exp.what() << (*signal_msg_dunmer_ptr).str() << std::endl;
std::ostringstream sout;
sout << platform::GetCurrentTraceBackString();
sout << "\n----------------------\nError Message "
"Summary:\n----------------------\n";
sout << platform::errors::Fatal(
"`%s` is detected by the operating system.",
ParseSignalErrorString(signal_info))
.to_string();
std::cout << sout.str() << (*signal_msg_dunmer_ptr).str() << std::endl;
}
} catch (...) {
// Since the program has already triggered a system error,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册