Install a Void::Stacktrace crash handler at plugin init

ts3plugin_init() sets a std::terminate handler that captures and prints a
symbolized stack trace (with source snippets) before aborting — useful for
diagnosing crashes in the hot-reloadable plugin. Link Void::Stacktrace.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Opus 4.8 committed 2026-06-22 21:27:00 +03:00
1 parent df1ea8d53f
commit 7c58af92cd
2 files changed
+18 -1

No files matched your search

+2 -1
View File
@@ -31,13 +31,14 @@ target_compile_definitions(EchoionPlugin PUBLIC PLUGIN=1)
# - ApiOpaque (OpaqueHandle for type-safe void*)
# - ApiPluginInterface (IPluginInterface to implement)
# - ApiCoreInterface (ICoreInterface to call Core - decoupled)
target_link_libraries(EchoionPlugin PRIVATE
target_link_libraries(EchoionPlugin PRIVATE
Echoion::ApiBase
Echoion::ApiPlugin
Echoion::ApiOpaque
Echoion::ApiPluginInterface
Echoion::ApiLogger
Echoion::ApiCoreInterface
Void::Stacktrace
)
find_package(dylib CONFIG REQUIRED)
+16
View File
@@ -3,6 +3,7 @@
#include "echoion/plugin/PluginInterface.hpp"
#include "teamspeak/public_errors.h"
#include <CoreInterface.hpp>
#include <Void/Stacktrace/Stacktrace.hpp>
#include <PluginTypes.hpp>
#include <Types.hpp>
#include <atomic>
@@ -254,6 +255,21 @@ namespace Echoion::Plugin
TS3_PLUGIN_API int ts3plugin_init()
{
std::cout << "[Echoion] Plugin init started" << std::endl;
// Install a terminate handler that dumps a symbolized stack trace
// (with source snippets) before the process dies — invaluable for
// diagnosing crashes in a hot-reloadable plugin.
static std::once_flag terminateOnce;
std::call_once(terminateOnce, [] {
std::set_terminate([] {
std::cerr << "[Echoion] FATAL: std::terminate — stack trace:\n";
const auto frames = Void::Stacktrace::capture_stacktrace();
std::cerr << Void::Stacktrace::format_stacktrace(frames)
<< std::endl;
std::abort();
});
});
g_deferredInitThread = std::jthread(deferredInitialization);
return 0;
}