backtrace: avoid duplicate backtrace objects.

This happened in my tal_dump(), and I couldn't see how we ended up
with object having more than one "backtrace".  Adding asserts that we
never added a second backtrace didn't trigger.

Finally I wondered if we were tal_steal() backtraces, and sure enough
we do that blinding in one place: libwally wrapping.  So fix that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2021-11-25 06:29:20 +10:30
parent 6c9b752751
commit c1f534a159

View File

@@ -32,8 +32,16 @@ void tal_wally_end(const tal_t *parent)
{
tal_t *p;
while ((p = tal_first(wally_tal_ctx)) != NULL) {
if (p != parent)
if (p != parent) {
#if DEVELOPER
/* Don't steal backtrace from wally_tal_ctx! */
if (tal_name(p) && streq(tal_name(p), "backtrace")) {
tal_free(p);
continue;
}
#endif /* DEVELOPER */
tal_steal(parent, p);
}
}
wally_tal_ctx = tal_free(wally_tal_ctx);
}