Skip to content

Project does not build with AddressSanitizer (ASan) #2277

@practicalswift

Description

@practicalswift

Hello fellow c-lightning developers!

Our project does not appear to build with AddressSanitizer (ASan):

$ git diff
diff --git a/Makefile b/Makefile
index fdbeff25..93dc4c35 100644
--- a/Makefile
+++ b/Makefile
@@ -179,7 +179,7 @@ ALL_PROGRAMS =

 CPPFLAGS = -DBINTOPKGLIBEXECDIR='"'$(shell sh tools/rel.sh $(bindir) $(pkglibexecdir))'"'
 CWARNFLAGS := -Werror -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition
-CDEBUGFLAGS := -std=gnu11 -g -fstack-protector
+CDEBUGFLAGS := -std=gnu11 -g -fstack-protector -fsanitize=address
 CFLAGS = $(CPPFLAGS) $(CWARNFLAGS) $(CDEBUGFLAGS) -I $(CCANDIR) $(EXTERNAL_INCLUDE_FLAGS) -I . -I/usr/local/include $(FEATURES) $(COVFLAGS) $(DEV_CFLAGS) -DSHACHAIN_BITS=48 -DJSMN_PARENT_LINKS $(PIE_CFLAGS) $(COMPAT_CFLAGS)

 # We can get configurator to run a different compile cmd to cross-configure.
diff --git a/configure b/configure
index c968d744..68f8ef57 100755
--- a/configure
+++ b/configure
@@ -7,7 +7,7 @@ set -e
 PREFIX=${PREFIX:-/usr/local}
 CC=${CC:-cc}
 CWARNFLAGS=${CWARNFLAGS:--Werror -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition}
-CDEBUGFLAGS=${CDEBUGFLAGS:--std=gnu11 -g -fstack-protector}
+CDEBUGFLAGS=${CDEBUGFLAGS:--std=gnu11 -g -fstack-protector -fsanitize=address}
 DEVELOPER=${DEVELOPER:-0}
 EXPERIMENTAL_FEATURES=${EXPERIMENTAL_FEATURES:-0}
 COMPAT=${COMPAT:-1}
$ CC="clang-7" ./configure
$ make
…
tools/headerversions.o: In function `main':
/.../lightning/tools/headerversions.c:52: undefined reference to `__asan_report_load8'

Is this a known issue?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions