mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
lightningd: fix backtraces in memleak detection.
We were using a *different* backtrace_state var, which was always NULL. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
c02ab124aa
commit
12a39b8a79
@@ -15,8 +15,9 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wally_core.h>
|
#include <wally_core.h>
|
||||||
|
|
||||||
|
struct backtrace_state *backtrace_state;
|
||||||
|
|
||||||
#if BACKTRACE_SUPPORTED
|
#if BACKTRACE_SUPPORTED
|
||||||
static struct backtrace_state *backtrace_state;
|
|
||||||
static void (*bt_print)(const char *fmt, ...) PRINTF_FMT(1,2);
|
static void (*bt_print)(const char *fmt, ...) PRINTF_FMT(1,2);
|
||||||
static void (*bt_exit)(void);
|
static void (*bt_exit)(void);
|
||||||
|
|
||||||
|
|||||||
@@ -10,4 +10,6 @@ void daemon_setup(const char *argv0,
|
|||||||
/* Shutdown for a valgrind-clean exit (frees everything) */
|
/* Shutdown for a valgrind-clean exit (frees everything) */
|
||||||
void daemon_shutdown(void);
|
void daemon_shutdown(void);
|
||||||
|
|
||||||
|
struct backtrace_state *backtrace_state;
|
||||||
|
|
||||||
#endif /* LIGHTNING_COMMON_DAEMON_H */
|
#endif /* LIGHTNING_COMMON_DAEMON_H */
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
#include <backtrace.h>
|
#include <backtrace.h>
|
||||||
#include <ccan/crypto/siphash24/siphash24.h>
|
#include <ccan/crypto/siphash24/siphash24.h>
|
||||||
#include <ccan/htable/htable.h>
|
#include <ccan/htable/htable.h>
|
||||||
|
#include <common/daemon.h>
|
||||||
#include <common/memleak.h>
|
#include <common/memleak.h>
|
||||||
|
|
||||||
#if DEVELOPER
|
#if DEVELOPER
|
||||||
static struct backtrace_state *backtrace_state;
|
|
||||||
static const void **notleaks;
|
static const void **notleaks;
|
||||||
static bool *notleak_children;
|
static bool *notleak_children;
|
||||||
|
|
||||||
@@ -226,10 +226,9 @@ static void add_backtrace(tal_t *parent UNUSED, enum tal_notify_type type UNNEED
|
|||||||
tal_add_notifier(child, TAL_NOTIFY_ADD_CHILD, add_backtrace);
|
tal_add_notifier(child, TAL_NOTIFY_ADD_CHILD, add_backtrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void memleak_init(const tal_t *root, struct backtrace_state *bstate)
|
void memleak_init(const tal_t *root)
|
||||||
{
|
{
|
||||||
assert(!notleaks);
|
assert(!notleaks);
|
||||||
backtrace_state = bstate;
|
|
||||||
notleaks = tal_arr(NULL, const void *, 0);
|
notleaks = tal_arr(NULL, const void *, 0);
|
||||||
notleak_children = tal_arr(notleaks, bool, 0);
|
notleak_children = tal_arr(notleaks, bool, 0);
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,9 @@
|
|||||||
void *notleak_(const void *ptr, bool plus_children);
|
void *notleak_(const void *ptr, bool plus_children);
|
||||||
|
|
||||||
struct htable;
|
struct htable;
|
||||||
struct backtrace_state;
|
|
||||||
|
|
||||||
/* Initialize memleak detection, with this as the root */
|
/* Initialize memleak detection, with this as the root */
|
||||||
void memleak_init(const tal_t *root, struct backtrace_state *bstate);
|
void memleak_init(const tal_t *root);
|
||||||
|
|
||||||
/* Free memleak detection. */
|
/* Free memleak detection. */
|
||||||
void memleak_cleanup(void);
|
void memleak_cleanup(void);
|
||||||
|
|||||||
@@ -41,8 +41,6 @@
|
|||||||
|
|
||||||
char *bitcoin_datadir;
|
char *bitcoin_datadir;
|
||||||
|
|
||||||
struct backtrace_state *backtrace_state;
|
|
||||||
|
|
||||||
int pid_fd;
|
int pid_fd;
|
||||||
|
|
||||||
static struct lightningd *new_lightningd(const tal_t *ctx)
|
static struct lightningd *new_lightningd(const tal_t *ctx)
|
||||||
@@ -56,7 +54,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
|||||||
ld->dev_allow_localhost = false;
|
ld->dev_allow_localhost = false;
|
||||||
|
|
||||||
if (getenv("LIGHTNINGD_DEV_MEMLEAK"))
|
if (getenv("LIGHTNINGD_DEV_MEMLEAK"))
|
||||||
memleak_init(ld, backtrace_state);
|
memleak_init(ld);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
list_head_init(&ld->peers);
|
list_head_init(&ld->peers);
|
||||||
|
|||||||
@@ -204,9 +204,6 @@ struct lightningd {
|
|||||||
|
|
||||||
const struct chainparams *get_chainparams(const struct lightningd *ld);
|
const struct chainparams *get_chainparams(const struct lightningd *ld);
|
||||||
|
|
||||||
/* State for performing backtraces. */
|
|
||||||
struct backtrace_state *backtrace_state;
|
|
||||||
|
|
||||||
/* Check we can run subdaemons, and check their versions */
|
/* Check we can run subdaemons, and check their versions */
|
||||||
void test_daemons(const struct lightningd *ld);
|
void test_daemons(const struct lightningd *ld);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#if DEVELOPER
|
#if DEVELOPER
|
||||||
#include <backtrace.h>
|
#include <backtrace.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
|
#include <common/daemon.h>
|
||||||
#include <common/memleak.h>
|
#include <common/memleak.h>
|
||||||
#include <lightningd/chaintopology.h>
|
#include <lightningd/chaintopology.h>
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user