From a158458b57dd9cf7dcd7939525074d9d201d5414 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Tue, 22 Sep 2020 21:59:58 +0200 Subject: [PATCH 1/2] dual-openingd: msg_type should be dualopend_wire not u8 clang did the hard work here: openingd/dualopend.c:958:42: error: result of comparison of constant 'WIRE_DUAL_OPEN_FAIL' (7003) with expression of type 'u8' (aka 'unsigned char') is always false [-Werror,-Wtautological-constant-out-of-range-compare] if ((msg_type = fromwire_peektype(msg)) == WIRE_DUAL_OPEN_FAIL) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~ Co-Authored-by: the clang compiler Signed-off-by: Antoine Poinsot --- openingd/dualopend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openingd/dualopend.c b/openingd/dualopend.c index e563db2d65bc..051060837361 100644 --- a/openingd/dualopend.c +++ b/openingd/dualopend.c @@ -853,7 +853,7 @@ static u8 *accepter_start(struct state *state, const u8 *oc2_msg) struct penalty_base *pbase; struct amount_msat our_msats; struct amount_sat total; - u8 msg_type; + enum dualopend_wire msg_type; state->our_role = ACCEPTER; open_tlv = tlv_opening_tlvs_new(tmpctx); From ad0676392e6e4e1d5f84125197e172265dc9b300 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Mon, 7 Sep 2020 16:14:07 +0200 Subject: [PATCH 2/2] configure: allow to run clang with ASAN Prefer adding LSAN_OPTIONS="suppressions=$PWD/tests/sanitizer_suppressions/lsan" when CC=clang instead. Changelog-Added: build: clang build now supports --enable-address-sanitizer . Signed-off-by: Antoine Poinsot --- configure | 4 ---- contrib/sanitizer_suppressions/asan | 3 +++ contrib/sanitizer_suppressions/lsan | 3 +++ 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 contrib/sanitizer_suppressions/asan create mode 100644 contrib/sanitizer_suppressions/lsan diff --git a/configure b/configure index 106d1995c1a4..62f5345d496c 100755 --- a/configure +++ b/configure @@ -223,10 +223,6 @@ $CC ${CWARNFLAGS-$BASE_WARNFLAGS} $CDEBUGFLAGS $COPTFLAGS -o $CONFIGURATOR $CONF echo "done" if [ "$ASAN" = "1" ]; then - if [ "$CC" = "clang" ]; then - echo "Address sanitizer (ASAN) is currently only supported with gcc" - exit 1 - fi if [ "$VALGRIND" = "1" ]; then echo "Address sanitizer (ASAN) and valgrind cannot be enabled at the same time" exit 1 diff --git a/contrib/sanitizer_suppressions/asan b/contrib/sanitizer_suppressions/asan new file mode 100644 index 000000000000..45c1ff249f94 --- /dev/null +++ b/contrib/sanitizer_suppressions/asan @@ -0,0 +1,3 @@ +# process_check_funding_broadcast is racy as it operates on a data that may be +# freed under its feet +interceptor_via_fun:process_check_funding_broadcast diff --git a/contrib/sanitizer_suppressions/lsan b/contrib/sanitizer_suppressions/lsan new file mode 100644 index 000000000000..f53dadfcf9ca --- /dev/null +++ b/contrib/sanitizer_suppressions/lsan @@ -0,0 +1,3 @@ +# Clang would detect false positive here, due to padding. See https://github.com/ElementsProject/lightning/pull/2285 +leak:ccan/ccan/autodata/autodata.c +leak:ccan/ccan/htable/htable.c