Skip to content

Commit

Permalink
[#100] fix(DaedalusVm): segfault in print_stack_trace with `Transie…
Browse files Browse the repository at this point in the history
…ntInstance`

Because `DaedalusTransientInstances` don't actually store a symbol index, the globals output of `print_stack_trace` will cause a crash because the symbol index being looked up is `-1`.
This patch adds a separate check for this case.
  • Loading branch information
lmichaelis committed Dec 9, 2024
1 parent 2eca0a1 commit 4adcbcb
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/DaedalusVm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -770,23 +770,28 @@ namespace zenkit {
for (auto* sym : symbols) {
if (sym == nullptr) continue;

if (auto instance = sym->get_instance(); instance != nullptr) {
auto instance = sym->get_instance();
if (instance != nullptr && instance->symbol_index() != static_cast<uint32_t>(-1)) {
DaedalusSymbol const* instance_symbol = find_symbol_by_instance(instance);
ZKLOGE("DaedalusVm",
"%s = %s (%u)",
sym->name().c_str(),
instance_symbol->name().c_str(),
instance->symbol_index());
} else {
} else if (instance == nullptr) {
ZKLOGE("DaedalusVm", "%s = NULL", sym->name().c_str());
} else {
ZKLOGE("DaedalusVm", "%s = <TRANSIENT>", sym->name().c_str());
}
}

if (_m_instance != nullptr) {
if (_m_instance != nullptr && _m_instance->symbol_index() != static_cast<uint32_t>(-1)) {
auto instance_symbol = find_symbol_by_instance(_m_instance);
ZKLOGE("DaedalusVm", "<__THIS__> = %s (%u)", instance_symbol->name().c_str(), _m_instance->symbol_index());
} else {
} else if (_m_instance == nullptr) {
ZKLOGE("DaedalusVm", "<__THIS__> = NULL");
} else {
ZKLOGE("DaedalusVm", "<__THIS__> = <TRANSIENT>");
}
}

Expand Down

0 comments on commit 4adcbcb

Please sign in to comment.