Fixed the issue where the Crash Stace Trace of the C++ part was overwritten by the Golang stack when starting the Golang module. #2171
+18
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
问题原因:
C++模块,启动的时候,会在比较靠前的位置InitCrashBackTrace()。InitCrashBackTrace会去注册SIGSEGV和SIGABRT的信号处理。然后启动Golang模块,Golang启动的时候,应该会去覆盖SIGSEGV和SIGABRT的信号处理
解决方案:
Golang启动之后,C++的信号处理重新设置一下即可。
测试方案:


C++ crash:
void Application::Start() 函数中,在LogtailPlugin::GetInstance()->LoadPluginBase();之后,设置空指针报错:
{
int* ptr = nullptr; // 声明一个空指针
std::cout << *ptr << std::endl; // 尝试解引用空指针,导致崩溃
}
本次修改之前的堆栈:
本次修改之后的堆栈:
Golang crash:


本次修改之前的堆栈:
手动panic
空指针
本次修改之后的堆栈:


手动panic
空指针