mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 13:25:43 +01:00
peer_control: don't refer to peer in copy_to_parent_log
Once we rely on the logbook outlasting the peer, we can't refer to the peer from the logbook function: Valgrind error file: valgrind-errors.26567 ==26567== Invalid read of size 8 ==26567== at 0x126297: copy_to_parent_log (peer_control.c:690) ==26567== by 0x11C06B: maybe_print (log.c:253) ==26567== by 0x11C145: logv (log.c:270) ==26567== by 0x11C448: log_ (log.c:319) ==26567== by 0x132951: destroy_subd (subd.c:537) ==26567== by 0x179C19: notify (tal.c:240) ==26567== by 0x17A0CE: del_tree (tal.c:400) ==26567== by 0x17A120: del_tree (tal.c:410) ==26567== by 0x17A4ED: tal_free (tal.c:509) ==26567== by 0x16DEB5: io_close (io.c:443) ==26567== by 0x1328BC: sd_msg_read (subd.c:516) ==26567== by 0x1320AC: read_fds (subd.c:328) ==26567== Address 0x6cf9ca0 is 48 bytes inside a block of size 216 free'd ==26567== at 0x4C30D3B: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==26567== by 0x17A1A9: del_tree (tal.c:421) ==26567== by 0x17A4ED: tal_free (tal.c:509) ==26567== by 0x124B6C: delete_peer (peer_control.c:180) ==26567== by 0x12B369: destroy_uncommitted_channel (peer_control.c:2505) ==26567== by 0x179C19: notify (tal.c:240) ==26567== by 0x17A0CE: del_tree (tal.c:400) ==26567== by 0x17A4ED: tal_free (tal.c:509) ==26567== by 0x12B31E: opening_channel_errmsg (peer_control.c:2496) ==26567== by 0x13243A: handle_peer_error (subd.c:407) ==26567== by 0x1326E4: sd_msg_read (subd.c:472) ==26567== by 0x1320AC: read_fds (subd.c:328) ==26567== Block was alloc'd at ==26567== at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==26567== by 0x179C83: allocate (tal.c:250) ==26567== by 0x17A250: tal_alloc_ (tal.c:448) ==26567== by 0x124950: new_peer (peer_control.c:151) ==26567== by 0x12B3EC: new_uncommitted_channel (peer_control.c:2521) ==26567== by 0x12B5C5: peer_accept_channel (peer_control.c:2569) ==26567== by 0x126099: peer_sent_nongossip (peer_control.c:641) ==26567== by 0x113B28: peer_nongossip (gossip_control.c:55) ==26567== by 0x113D9D: gossip_msg (gossip_control.c:144) ==26567== by 0x132783: sd_msg_read (subd.c:487) ==26567== by 0x1320AC: read_fds (subd.c:328) ==26567== by 0x16D1FE: next_plan (io.c:59) ==26567== Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
7c512f91ce
commit
1a78efaee5
@ -61,7 +61,7 @@ static void copy_to_parent_log(const char *prefix,
|
|||||||
const struct timeabs *time,
|
const struct timeabs *time,
|
||||||
const char *str,
|
const char *str,
|
||||||
const u8 *io,
|
const u8 *io,
|
||||||
struct peer *peer);
|
struct log *parent_log);
|
||||||
static void peer_offer_channel(struct lightningd *ld,
|
static void peer_offer_channel(struct lightningd *ld,
|
||||||
struct funding_channel *fc,
|
struct funding_channel *fc,
|
||||||
const struct wireaddr *addr,
|
const struct wireaddr *addr,
|
||||||
@ -113,7 +113,7 @@ struct peer *new_peer(struct lightningd *ld, u64 dbid,
|
|||||||
|
|
||||||
/* Max 128k per peer. */
|
/* Max 128k per peer. */
|
||||||
peer->log_book = new_log_book(128*1024, get_log_level(ld->log_book));
|
peer->log_book = new_log_book(128*1024, get_log_level(ld->log_book));
|
||||||
set_log_outfn(peer->log_book, copy_to_parent_log, peer);
|
set_log_outfn(peer->log_book, copy_to_parent_log, ld->log);
|
||||||
list_add_tail(&ld->peers, &peer->list);
|
list_add_tail(&ld->peers, &peer->list);
|
||||||
tal_add_destructor(peer, destroy_peer);
|
tal_add_destructor(peer, destroy_peer);
|
||||||
return peer;
|
return peer;
|
||||||
@ -541,14 +541,14 @@ static void copy_to_parent_log(const char *prefix,
|
|||||||
const struct timeabs *time,
|
const struct timeabs *time,
|
||||||
const char *str,
|
const char *str,
|
||||||
const u8 *io,
|
const u8 *io,
|
||||||
struct peer *peer)
|
struct log *parent_log)
|
||||||
{
|
{
|
||||||
if (level == LOG_IO_IN || level == LOG_IO_OUT)
|
if (level == LOG_IO_IN || level == LOG_IO_OUT)
|
||||||
log_io(peer->ld->log, level, prefix, io, tal_len(io));
|
log_io(parent_log, level, prefix, io, tal_len(io));
|
||||||
else if (continued)
|
else if (continued)
|
||||||
log_add(peer->ld->log, "%s ... %s", prefix, str);
|
log_add(parent_log, "%s ... %s", prefix, str);
|
||||||
else
|
else
|
||||||
log_(peer->ld->log, level, "%s %s", prefix, str);
|
log_(parent_log, level, "%s %s", prefix, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct peer *peer_by_id(struct lightningd *ld, const struct pubkey *id)
|
struct peer *peer_by_id(struct lightningd *ld, const struct pubkey *id)
|
||||||
|
Loading…
Reference in New Issue
Block a user