This happens with autoclean, which does a datastore request then frees the parent command without waiting for a response (see clean_finished). This leaks a trace, and causes a crash if the pointer is later reused. My solution is to create a trace variant which declares the trace key to be a tal ptr and then we can clean up in the destructor if this happens. This fixes the issue for me. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Fixed: autoclean: fixed occasional crash when tracepoints compiled in.
25 lines
971 B
C
25 lines
971 B
C
#ifndef LIGHTNING_COMMON_TRACE_H
|
|
#define LIGHTNING_COMMON_TRACE_H
|
|
#include "config.h"
|
|
#include <ccan/short_types/short_types.h>
|
|
|
|
#define SPAN_ID_SIZE 8
|
|
#define TRACE_ID_SIZE 16
|
|
#undef TRACE_DEBUG
|
|
|
|
void trace_span_start(const char *name, const void *key);
|
|
void trace_span_end(const void *key);
|
|
void trace_span_tag(const void *key, const char *name, const char *value);
|
|
void trace_cleanup(void);
|
|
void trace_span_remote(u8 trace_id[TRACE_ID_SIZE], u8 span_id[SPAN_ID_SIZE]);
|
|
|
|
#define TRACE_LBL __FILE__ ":" stringify(__LINE__)
|
|
void trace_span_suspend_(const void *key, const char *lbl);
|
|
void trace_span_suspend_may_free_(const void *key, const char *lbl);
|
|
void trace_span_resume_(const void *key, const char *lbl);
|
|
#define trace_span_suspend(key) trace_span_suspend_(key, TRACE_LBL)
|
|
#define trace_span_suspend_may_free(key) trace_span_suspend_may_free_(key, TRACE_LBL)
|
|
#define trace_span_resume(key) trace_span_resume_(key, TRACE_LBL)
|
|
|
|
#endif /* LIGHTNING_COMMON_TRACE_H */
|