fix: incorrect borrow annotation on demangleBtLinCStr leading to segfault on panic (#12939)

This commit is contained in:
Sebastian Ullrich
2026-03-17 10:24:57 +01:00
committed by GitHub
parent 6714601ee4
commit 3c32607020
2 changed files with 3 additions and 9 deletions

View File

@@ -333,11 +333,7 @@ public def demangleBtLine (line : String) : Option String := do
return pfx ++ demangled ++ sfx return pfx ++ demangled ++ sfx
@[export lean_demangle_bt_line_cstr] @[export lean_demangle_bt_line_cstr]
def demangleBtLineCStr (line : @& String) : String := def demangleBtLineCStr (line : String) : String :=
(demangleBtLine line).getD "" (demangleBtLine line).getD ""
@[export lean_demangle_symbol_cstr]
def demangleSymbolCStr (symbol : @& String) : String :=
(demangleSymbol symbol).getD ""
end Lean.Name.Demangle end Lean.Name.Demangle

View File

@@ -34,7 +34,7 @@ Author: Leonardo de Moura
// Lean-exported demangler from Lean.Compiler.NameDemangling. // Lean-exported demangler from Lean.Compiler.NameDemangling.
// Declared as a weak symbol so leanrt doesn't require libLean at link time. // Declared as a weak symbol so leanrt doesn't require libLean at link time.
// When the Lean demangler is linked in, it overrides this stub. // When the Lean demangler is linked in, it overrides this stub.
extern "C" __attribute__((weak)) lean_object * lean_demangle_bt_line_cstr(lean_object * s) { extern "C" __attribute__((weak)) lean_obj_res lean_demangle_bt_line_cstr(lean_obj_arg s) {
lean_dec(s); lean_dec(s);
return lean_mk_string(""); return lean_mk_string("");
} }
@@ -150,11 +150,9 @@ static void print_backtrace(bool force_stderr) {
if (result_str[0] != '\0') { if (result_str[0] != '\0') {
panic_eprintln(result_str, force_stderr); panic_eprintln(result_str, force_stderr);
lean_dec(result); lean_dec(result);
lean_dec(line_obj);
continue; continue;
} }
lean_dec(result); lean_dec(result);
lean_dec(line_obj);
} }
panic_eprintln(symbols[i], force_stderr); panic_eprintln(symbols[i], force_stderr);
} }
@@ -791,7 +789,7 @@ class task_manager {
// idle before picking up new work. // idle before picking up new work.
// But during shutdown, we skip this throttling: // But during shutdown, we skip this throttling:
// because the finalizer might have called m_queue_cv.notify_all() for the last // because the finalizer might have called m_queue_cv.notify_all() for the last
// time, we don't want to get stuck behind the wait(). // time, we don't want to get stuck behind the wait().
if (!m_shutting_down && if (!m_shutting_down &&
m_std_workers.size() - m_idle_std_workers >= m_max_std_workers) { m_std_workers.size() - m_idle_std_workers >= m_max_std_workers) {
m_queue_cv.wait(lock); m_queue_cv.wait(lock);