[2/2] Add configure option for asan

Message ID 20210306185505.162118-2-jonatan.schlag@ipfire.org
State Dropped
Headers
Series [1/2] Add configure option for fanalyzer |

Commit Message

Jonatan Schlag March 6, 2021, 6:55 p.m. UTC
  Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
---
 Makefile.am  |  3 ++-
 configure.ac | 26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)
  

Comments

Jonatan Schlag March 6, 2021, 7:04 p.m. UTC | #1
Hi,

results with these two options are attached.

Greetings Jonatan

Am Samstag, den 06.03.2021, 19:55 +0100 schrieb Jonatan Schlag:
> Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
> ---
>  Makefile.am  |  3 ++-
>  configure.ac | 26 ++++++++++++++++++++++++++
>  2 files changed, 28 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile.am b/Makefile.am
> index 0c2f78c..7782354 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -19,11 +19,12 @@ AM_CPPFLAGS = \
>  	-I${top_srcdir}/src
>  
>  AM_CFLAGS = ${warn_CFLAGS} \
> +	${asan_CFLAGS} \
>  	${my_CFLAGS} \
>  	-ffunction-sections \
>  	-fdata-sections
>  
> -AM_LDFLAGS =
> +AM_LDFLAGS = ${asan_LDFLAGS}
>  
>  # leaving a space here to work around automake's conditionals
>   ifeq ($(OS),Darwin)
> diff --git a/configure.ac b/configure.ac
> index dd1ca64..6a4ee0c 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -104,6 +104,32 @@ AS_IF([test "x$more_warnings" = "xyes"],[
>  
>  AC_SUBST([warn_CFLAGS])
>  
> +# - asan ---------------------------------------------------------
> --------------
> +
> +asan_CFLAGS=""
> +asan_LDFLAGS=""
> +
> +AC_ARG_ENABLE([asan],
> +        AS_HELP_STRING([--enable-asan], [enable the address
> sanitizer @<:@default=disabled@:>@]),
> +        [asan=yes], [asan=no])
> +AS_IF([test "x$asan" = "xyes"],[
> +	asan_CFLAGS+="\
> +	-g \
> +	-fsanitize=address \
> +	-fno-omit-frame-pointer \
> +	-fsanitize-recover=address \
> +	"
> +
> +	asan_LDFLAGS+="\
> +	-fsanitize=address \
> +	"
> +])
> +
> +AC_SUBST([asan_CFLAGS])
> +AC_SUBST([asan_LDFLAGS])
> +
> +# ------------------------------------------------------------------
> ------------
> +
>  my_CFLAGS="\
>  -Wall \
>  -Wchar-subscripts \
====================================
   libloc 0.9.5: ./test-suite.log
====================================

# TOTAL: 7
# PASS:  4
# SKIP:  0
# XFAIL: 0
# FAIL:  3
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

FAIL: src/test-database
=======================

libloc: loc_database_read_magic: Could not read enough data to validate magic bytes
libloc: loc_database_read_magic: Unrecognized file type
libloc: loc_database_read_magic: Unrecognized file type
libloc: loc_database_read_as_section_v1: Read 0 ASes from the database
libloc: loc_database_read_network_nodes_section_v1: Read 69 network nodes from the database
libloc: loc_database_read_networks_section_v1: Read 4 networks from the database
libloc: loc_database_read_countries_section_v1: Read 0 countries from the database
libloc: loc_database_read: Opened database in 0.1160ms

=================================================================
==165192==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 256 byte(s) in 4 object(s) allocated from:
    #0 0x7f6819543037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7f681947dc22 in loc_network_new src/network.c:148
    #2 0x7f681947eb4d in loc_network_new_from_string src/network.c:225
    #3 0x7f681948cf8b in loc_writer_add_network src/writer.c:257
    #4 0x559919916639 in main src/test-database.c:155
    #5 0x7f68192ccd09 in __libc_start_main ../csu/libc-start.c:308

Direct leak of 256 byte(s) in 4 object(s) allocated from:
    #0 0x7f6819543037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7f681947dc22 in loc_network_new src/network.c:148
    #2 0x7f68194814e1 in loc_network_new_from_database_v1 src/network.c:765
    #3 0x7f6819476c2b in loc_database_fetch_network src/database.c:743
    #4 0x7f6819476c2b in __loc_database_enumerator_next_network src/database.c:1260
    #5 0x5599199167fa in main src/test-database.c:209
    #6 0x7f68192ccd09 in __libc_start_main ../csu/libc-start.c:308

Indirect leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7f6819543037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7f681947325a in loc_new src/libloc.c:78
    #2 0x5599199163b7 in main src/test-database.c:74
    #3 0x7f68192ccd09 in __libc_start_main ../csu/libc-start.c:308

SUMMARY: AddressSanitizer: 536 byte(s) leaked in 9 allocation(s).
FAIL src/test-database (exit status: 1)

FAIL: src/test-as
=================

libloc: loc_database_read_as_section_v1: Read 5000 ASes from the database
libloc: loc_database_read_network_nodes_section_v1: Read 1 network nodes from the database
libloc: loc_database_read_networks_section_v1: Read 0 networks from the database
libloc: loc_database_read_countries_section_v1: Read 0 countries from the database
libloc: loc_database_read: Opened database in 0.1760ms
Found AS10: Test AS10
Found AS100: Test AS100
Found AS101: Test AS101
Found AS102: Test AS102
Found AS103: Test AS103
Found AS104: Test AS104
Found AS105: Test AS105
Found AS106: Test AS106
Found AS107: Test AS107
Found AS108: Test AS108
Found AS109: Test AS109
Found AS110: Test AS110
Found AS210: Test AS210
Found AS310: Test AS310
Found AS410: Test AS410
Found AS510: Test AS510
Found AS610: Test AS610
Found AS710: Test AS710
Found AS810: Test AS810
Found AS910: Test AS910
Found AS1000: Test AS1000
Found AS1001: Test AS1001
Found AS1002: Test AS1002
Found AS1003: Test AS1003
Found AS1004: Test AS1004
Found AS1005: Test AS1005
Found AS1006: Test AS1006
Found AS1007: Test AS1007
Found AS1008: Test AS1008
Found AS1009: Test AS1009
Found AS1010: Test AS1010
Found AS1011: Test AS1011
Found AS1012: Test AS1012
Found AS1013: Test AS1013
Found AS1014: Test AS1014
Found AS1015: Test AS1015
Found AS1016: Test AS1016
Found AS1017: Test AS1017
Found AS1018: Test AS1018
Found AS1019: Test AS1019
Found AS1020: Test AS1020
Found AS1021: Test AS1021
Found AS1022: Test AS1022
Found AS1023: Test AS1023
Found AS1024: Test AS1024
Found AS1025: Test AS1025
Found AS1026: Test AS1026
Found AS1027: Test AS1027
Found AS1028: Test AS1028
Found AS1029: Test AS1029
Found AS1030: Test AS1030
Found AS1031: Test AS1031
Found AS1032: Test AS1032
Found AS1033: Test AS1033
Found AS1034: Test AS1034
Found AS1035: Test AS1035
Found AS1036: Test AS1036
Found AS1037: Test AS1037
Found AS1038: Test AS1038
Found AS1039: Test AS1039
Found AS1040: Test AS1040
Found AS1041: Test AS1041
Found AS1042: Test AS1042
Found AS1043: Test AS1043
Found AS1044: Test AS1044
Found AS1045: Test AS1045
Found AS1046: Test AS1046
Found AS1047: Test AS1047
Found AS1048: Test AS1048
Found AS1049: Test AS1049
Found AS1050: Test AS1050
Found AS1051: Test AS1051
Found AS1052: Test AS1052
Found AS1053: Test AS1053
Found AS1054: Test AS1054
Found AS1055: Test AS1055
Found AS1056: Test AS1056
Found AS1057: Test AS1057
Found AS1058: Test AS1058
Found AS1059: Test AS1059
Found AS1060: Test AS1060
Found AS1061: Test AS1061
Found AS1062: Test AS1062
Found AS1063: Test AS1063
Found AS1064: Test AS1064
Found AS1065: Test AS1065
Found AS1066: Test AS1066
Found AS1067: Test AS1067
Found AS1068: Test AS1068
Found AS1069: Test AS1069
Found AS1070: Test AS1070
Found AS1071: Test AS1071
Found AS1072: Test AS1072
Found AS1073: Test AS1073
Found AS1074: Test AS1074
Found AS1075: Test AS1075
Found AS1076: Test AS1076
Found AS1077: Test AS1077
Found AS1078: Test AS1078
Found AS1079: Test AS1079
Found AS1080: Test AS1080
Found AS1081: Test AS1081
Found AS1082: Test AS1082
Found AS1083: Test AS1083
Found AS1084: Test AS1084
Found AS1085: Test AS1085
Found AS1086: Test AS1086
Found AS1087: Test AS1087
Found AS1088: Test AS1088
Found AS1089: Test AS1089
Found AS1090: Test AS1090
Found AS1091: Test AS1091
Found AS1092: Test AS1092
Found AS1093: Test AS1093
Found AS1094: Test AS1094
Found AS1095: Test AS1095
Found AS1096: Test AS1096
Found AS1097: Test AS1097
Found AS1098: Test AS1098
Found AS1099: Test AS1099
Found AS1100: Test AS1100
Found AS1101: Test AS1101
Found AS1102: Test AS1102
Found AS1103: Test AS1103
Found AS1104: Test AS1104
Found AS1105: Test AS1105
Found AS1106: Test AS1106
Found AS1107: Test AS1107
Found AS1108: Test AS1108
Found AS1109: Test AS1109
Found AS1110: Test AS1110
Found AS1210: Test AS1210
Found AS1310: Test AS1310
Found AS1410: Test AS1410
Found AS1510: Test AS1510
Found AS1610: Test AS1610
Found AS1710: Test AS1710
Found AS1810: Test AS1810
Found AS1910: Test AS1910
Found AS2010: Test AS2010
Found AS2100: Test AS2100
Found AS2101: Test AS2101
Found AS2102: Test AS2102
Found AS2103: Test AS2103
Found AS2104: Test AS2104
Found AS2105: Test AS2105
Found AS2106: Test AS2106
Found AS2107: Test AS2107
Found AS2108: Test AS2108
Found AS2109: Test AS2109
Found AS2110: Test AS2110
Found AS2210: Test AS2210
Found AS2310: Test AS2310
Found AS2410: Test AS2410
Found AS2510: Test AS2510
Found AS2610: Test AS2610
Found AS2710: Test AS2710
Found AS2810: Test AS2810
Found AS2910: Test AS2910
Foun
=================================================================
==165214==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4752 byte(s) in 198 object(s) allocated from:
    #0 0x7f0db3575037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7f0db34a57d6 in loc_as_new src/as.c:43
    #2 0x7f0db34a5bdc in loc_as_new_from_database_v1 src/as.c:118
    #3 0x7f0db34aec4c in loc_database_fetch_as src/database.c:666
    #4 0x7f0db34aec4c in loc_database_enumerator_next_as src/database.c:1106
    #5 0x556c1a7b9710 in main src/test-as.c:115
    #6 0x7f0db32fed09 in __libc_start_main ../csu/libc-start.c:308

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7f0db3575037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7f0db34a57d6 in loc_as_new src/as.c:43
    #2 0x7f0db34a5bdc in loc_as_new_from_database_v1 src/as.c:118
    #3 0x7f0db34aec4c in loc_database_fetch_as src/database.c:666
    #4 0x7f0db34aec4c in loc_database_enumerator_next_as src/database.c:1106
    #5 0x556c1a7b969f in main src/test-as.c:106
    #6 0x7f0db32fed09 in __libc_start_main ../csu/libc-start.c:308

Indirect leak of 2357 byte(s) in 198 object(s) allocated from:
    #0 0x7f0db3522817 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:452
    #1 0x7f0db34a5a81 in loc_as_set_name src/as.c:97
    #2 0x7f0db34a5c45 in loc_as_new_from_database_v1 src/as.c:123
    #3 0x7f0db34aec4c in loc_database_fetch_as src/database.c:666
    #4 0x7f0db34aec4c in loc_database_enumerator_next_as src/database.c:1106
    #5 0x556c1a7b9710 in main src/test-as.c:115
    #6 0x7f0db32fed09 in __libc_start_main ../csu/libc-start.c:308

Indirect leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7f0db3575037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7f0db34a525a in loc_new src/libloc.c:78
    #2 0x556c1a7b9375 in main src/test-as.c:32
    #3 0x7f0db32fed09 in __libc_start_main ../csu/libc-start.c:308

Indirect leak of 10 byte(s) in 1 object(s) allocated from:
    #0 0x7f0db3522817 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:452
    #1 0x7f0db34a5a81 in loc_as_set_name src/as.c:97
    #2 0x7f0db34a5c45 in loc_as_new_from_database_v1 src/as.c:123
    #3 0x7f0db34aec4c in loc_database_fetch_as src/database.c:666
    #4 0x7f0db34aec4c in loc_database_enumerator_next_as src/database.c:1106
    #5 0x556c1a7b969f in main src/test-as.c:106
    #6 0x7f0db32fed09 in __libc_start_main ../csu/libc-start.c:308

SUMMARY: AddressSanitizer: 7167 byte(s) leaked in 399 allocation(s).
FAIL src/test-as (exit status: 1)

FAIL: src/test-network
======================

libloc: loc_network_list_dump:    0: 2001:db8::/33
libloc: loc_network_list_dump:    1: 2001:db8:8000::/34
libloc: loc_network_list_dump:    2: 2001:db8:c000::/35
libloc: loc_network_list_dump:    3: 2001:db8:e000::/36
libloc: loc_network_list_dump:    4: 2001:db8:f000::/37
libloc: loc_network_list_dump:    5: 2001:db8:f800::/38
libloc: loc_network_list_dump:    6: 2001:db8:fc00::/39
libloc: loc_network_list_dump:    7: 2001:db8:fe00::/40
libloc: loc_network_list_dump:    8: 2001:db8:ff00::/41
libloc: loc_network_list_dump:    9: 2001:db8:ff80::/42
libloc: loc_network_list_dump:   10: 2001:db8:ffc0::/43
libloc: loc_network_list_dump:   11: 2001:db8:ffe0::/44
libloc: loc_network_list_dump:   12: 2001:db8:fff0::/45
libloc: loc_network_list_dump:   13: 2001:db8:fff8::/46
libloc: loc_network_list_dump:   14: 2001:db8:fffc::/47
libloc: loc_network_list_dump:   15: 2001:db8:fffe::/48
libloc: loc_database_read_as_section_v1: Read 0 ASes from the database
libloc: loc_database_read_network_nodes_section_v1: Read 161 network nodes from the database
libloc: loc_database_read_networks_section_v1: Read 3 networks from the database
libloc: loc_database_read_countries_section_v1: Read 0 countries from the database
libloc: loc_database_read: Opened database in 0.0870ms
=================================================================
==165239==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff74d54cc0 at pc 0x7fbda6e59448 bp 0x7fff74d51b80 sp 0x7fff74d51b78
READ of size 1 at 0x7fff74d54cc0 thread T0
    #0 0x7fbda6e59447 in in6_addr_get_bit src/loc/private.h:74
    #1 0x7fbda6e59447 in __loc_database_lookup src/database.c:802
    #2 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #3 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #4 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #5 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #6 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #7 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #8 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #9 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #10 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #11 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #12 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #13 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #14 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #15 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #16 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #17 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #18 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #19 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #20 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #21 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #22 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #23 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #24 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #25 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #26 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #27 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #28 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #29 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #30 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #31 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #32 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #33 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #34 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #35 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #36 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #37 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #38 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #39 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #40 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #41 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #42 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #43 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #44 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #45 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #46 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #47 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #48 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #49 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #50 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #51 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #52 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #53 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #54 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #55 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #56 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #57 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #58 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #59 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #60 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #61 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #62 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #63 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #64 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #65 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #66 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #67 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #68 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #69 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #70 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #71 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #72 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #73 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #74 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #75 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #76 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #77 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #78 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #79 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #80 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #81 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #82 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #83 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #84 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #85 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #86 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #87 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #88 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #89 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #90 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #91 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #92 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #93 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #94 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #95 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #96 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #97 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #98 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #99 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #100 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #101 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #102 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #103 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #104 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #105 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #106 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #107 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #108 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #109 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #110 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #111 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #112 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #113 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #114 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #115 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #116 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #117 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #118 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #119 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #120 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #121 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #122 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #123 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #124 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #125 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #126 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #127 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #128 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #129 0x7fbda6e5920a in __loc_database_lookup src/database.c:818
    #130 0x7fbda6e5eebd in loc_database_lookup src/database.c:856
    #131 0x7fbda6e5efcf in loc_database_lookup_from_string src/database.c:878
    #132 0x55b300fe6cfa in main src/test-network.c:299
    #133 0x7fbda6cafd09 in __libc_start_main ../csu/libc-start.c:308
    #134 0x55b300fe7aa9 in _start (/root/libloc/src/.libs/test-network+0x3aa9)

Address 0x7fff74d54cc0 is located in stack of thread T0 at offset 48 in frame
    #0 0x7fbda6e5ef3f in loc_database_lookup_from_string src/database.c:871

  This frame has 1 object(s):
    [32, 48) 'address' (line 872) <== Memory access at offset 48 overflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow src/loc/private.h:74 in in6_addr_get_bit
Shadow bytes around the buggy address:
  0x10006e9a2940: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10006e9a2950: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10006e9a2960: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10006e9a2970: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10006e9a2980: f1 f1 f1 f1 00 00 f3 f3 00 00 00 00 00 00 00 00
=>0x10006e9a2990: 00 00 f1 f1 f1 f1 00 00[f3]f3 00 00 00 00 00 00
  0x10006e9a29a0: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 00 f2 f2 f2
  0x10006e9a29b0: 00 f2 f2 f2 00 f2 f2 f2 00 f2 f2 f2 00 f2 f2 f2
  0x10006e9a29c0: 00 f2 f2 f2 00 f2 f2 f2 00 f2 f2 f2 00 f2 f2 f2
  0x10006e9a29d0: 00 f2 f2 f2 00 00 f3 f3 00 00 00 00 00 00 00 00
  0x10006e9a29e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==165239==ABORTING
FAIL src/test-network (exit status: 1)
Making check in .
cd ./src/perl && /usr/bin/perl Makefile.PL INSTALLDIRS=vendor \
	INC="-I/root/libloc/src" LIBS="-L/root/libloc/src/.libs -lloc"
Generating a Unix-style Makefile
Writing Makefile for Location
Writing MYMETA.yml and MYMETA.json
cd ./src/perl && make LD_RUN_PATH=
Skip blib/lib/Location.pm (unchanged)
Running Mkbootstrap for Location ()
chmod 644 "Location.bs"
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Location.bs blib/arch/auto/Location/Location.bs 644
x86_64-linux-gnu-gcc -c  -I/root/libloc/src -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g   -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" -fPIC "-I/usr/lib/x86_64-linux-gnu/perl/5.32/CORE"   Location.c
rm -f blib/arch/auto/Location/Location.so
LD_RUN_PATH="" x86_64-linux-gnu-gcc  -shared -L/usr/local/lib -fstack-protector-strong  Location.o  -o blib/arch/auto/Location/Location.so  \
   -L/root/libloc/src/.libs -lloc   \
  
chmod 755 blib/arch/auto/Location/Location.so
Manifying 1 pod document
make --no-print-directory src/test-libloc src/test-stringpool src/test-database src/test-as src/test-network src/test-network-list src/test-country src/test-signature
  CC       src/test_libloc-test-libloc.o
  CCLD     src/test-libloc
  CC       src/test_stringpool-test-stringpool.o
src/test-stringpool.c: In function ‘random_string’:
src/test-stringpool.c:39:8: warning: dereference of possibly-NULL ‘p’ [CWE-690] [-Wanalyzer-possible-null-dereference]
   39 |   *p++ = characters[rand() % strlen(characters)];
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ‘main’: events 1-14
    |
    |   46 | int main(int argc, char** argv) {
    |      |     ^~~~
    |      |     |
    |      |     (1) entry to ‘main’
    |......
    |   55 |  if (err < 0)
    |      |     ~
    |      |     |
    |      |     (2) following ‘false’ branch (when ‘err >= 0’)...
    |......
    |   59 |  loc_set_log_priority(ctx, LOG_DEBUG);
    |      |  ~~~~~~~~~~~~~~~~~~~~
    |      |  |
    |      |  (3) ...to here
    |......
    |   64 |  if (err < 0)
    |      |     ~
    |      |     |
    |      |     (4) following ‘false’ branch (when ‘err >= 0’)...
    |......
    |   68 |  const char* s = loc_stringpool_get(pool, 100);
    |      |  ~~~~~
    |      |  |
    |      |  (5) ...to here
    |   69 |  if (s != NULL) {
    |      |     ~
    |      |     |
    |      |     (6) following ‘false’ branch (when ‘s’ is NULL)...
    |......
    |   75 |  off_t pos = loc_stringpool_add(pool, "ABC");
    |      |  ~~~~~
    |      |  |
    |      |  (7) ...to here
    |   76 |  if (pos < 0) {
    |      |     ~
    |      |     |
    |      |     (8) following ‘false’ branch (when ‘pos >= 0’)...
    |......
    |   81 |  printf("Added string at %jd\n", (intmax_t)pos);
    |      |  ~~~~~~
    |      |  |
    |      |  (9) ...to here
    |......
    |   84 |  if (pos != 0) {
    |      |     ~
    |      |     |
    |      |     (10) following ‘false’ branch (when ‘pos == 0’)...
    |......
    |   90 |  pos = loc_stringpool_add(pool, "ABC");
    |      |  ~~~ 
    |      |  |
    |      |  (11) ...to here
    |   91 |  if (pos != 0) {
    |      |     ~
    |      |     |
    |      |     (12) following ‘false’ branch (when ‘pos == 0’)...
    |......
    |   97 |  pos = loc_stringpool_add(pool, "DEF");
    |      |  ~~~ 
    |      |  |
    |      |  (13) ...to here
    |   98 |  if (pos == 0) {
    |      |     ~
    |      |     |
    |      |     (14) following ‘false’ branch (when ‘pos != 0’)...
    |
  ‘main’: event 15
    |
    |cc1:
    | (15): ...to here
    |
  ‘main’: events 16-18
    |
    |  104 |  for (unsigned int i = 0; i < 10000; i++) {
    |      |  ^~~
    |      |  |
    |      |  (16) following ‘true’ branch (when ‘i != 10000’)...
    |  105 |   char* string = random_string(3);
    |      |   ~~~~           ~~~~~~~~~~~~~~~~
    |      |   |              |
    |      |   |              (18) calling ‘random_string’ from ‘main’
    |      |   (17) ...to here
    |
    +--> ‘random_string’: events 19-23
           |
           |   34 | static char* random_string(size_t size) {
           |      |              ^~~~~~~~~~~~~
           |      |              |
           |      |              (19) entry to ‘random_string’
           |   35 |  char* string = malloc(size + 1);
           |      |  ~~~~         
           |      |  |
           |      |  (20) this call could return NULL
           |......
           |   38 |  for (unsigned int i = 0; i < size; i++) {
           |      |  ~~~          
           |      |  |
           |      |  (21) following ‘true’ branch...
           |   39 |   *p++ = characters[rand() % strlen(characters)];
           |      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |   |    |
           |      |   |    (23) ‘p’ could be NULL: unchecked value from (20)
           |      |   (22) ...to here
           |
  CCLD     src/test-stringpool
  CC       src/test_database-test-database.o
  CCLD     src/test-database
  CC       src/test_as-test-as.o
  CCLD     src/test-as
  CC       src/test_network-test-network.o
  CCLD     src/test-network
  CC       src/test_network_list-test-network-list.o
  CCLD     src/test-network-list
  CC       src/test_country-test-country.o
  CCLD     src/test-country
  CC       src/test_signature-test-signature.o
  CCLD     src/test-signature
make --no-print-directory check-TESTS check-local
PASS: src/test-libloc
PASS: src/test-stringpool
FAIL: src/test-database
FAIL: src/test-as
FAIL: src/test-network
PASS: src/test-country
PASS: src/test-signature
============================================================================
Testsuite summary for libloc 0.9.5
============================================================================
# TOTAL: 7
# PASS:  4
# SKIP:  0
# XFAIL: 0
# FAIL:  3
# XPASS: 0
# ERROR: 0
============================================================================
See ./test-suite.log
Please report to location@lists.ipfire.org
============================================================================
make[3]: *** [Makefile:1961: test-suite.log] Error 1
make[2]: *** [Makefile:2069: check-TESTS] Error 2
make[1]: *** [Makefile:2348: check-am] Error 2
make: *** [Makefile:1846: check-recursive] Error 1
make --no-print-directory all-recursive
Making all in .
  CC       src/libloc_la-libloc.lo
  CC       src/libloc_la-as.lo
  CC       src/libloc_la-as-list.lo
  CC       src/libloc_la-country.lo
  CC       src/libloc_la-country-list.lo
  CC       src/libloc_la-database.lo
src/database.c: In function ‘loc_database_created_at’:
src/database.c:634:8: warning: variable ‘memoryArea’ set but not used [-Wunused-but-set-variable]
  634 |  char *memoryArea = malloc(10);
      |        ^~~~~~~~~~
In function ‘loc_database_enumerator_new’:
src/database.c:1014:2: warning: leak of ‘<unknown>’ [CWE-401] [-Wanalyzer-malloc-leak]
 1014 |  return 0;
      |  ^~~~~~
  ‘loc_database_enumerator_new’: events 1-4
    |
    |  988 |  if (!e)
    |      |     ^
    |      |     |
    |      |     (1) following ‘false’ branch (when ‘e’ is non-NULL)...
    |......
    |  992 |  e->ctx = loc_ref(db->ctx);
    |      |  ~   
    |      |  |
    |      |  (2) ...to here
    |  993 |  e->db = loc_database_ref(db);
    |      |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |        |
    |      |        (3) allocated here
    |......
    | 1006 |  if (r) {
    |      |     ~
    |      |     |
    |      |     (4) following ‘false’ branch (when ‘r == 0’)...
    |
  ‘loc_database_enumerator_new’: event 5
    |
    |./src/loc/private.h:41:30:
    |   41 | #  define DEBUG(ctx, arg...) loc_log_null(ctx, ## arg)
    |      |                              ^~~~~~~~~~~~
    |      |                              |
    |      |                              (5) ...to here
src/database.c:1011:2: note: in expansion of macro ‘DEBUG’
    | 1011 |  DEBUG(e->ctx, "Database enumerator object allocated at %p\n", e);
    |      |  ^~~~~
    |
  ‘loc_database_enumerator_new’: event 6
    |
    | 1014 |  return 0;
    |      |  ^~~~~~
    |      |  |
    |      |  (6) ‘<unknown>’ leaks here; was allocated at (3)
    |
  CC       src/libloc_la-network.lo
  CC       src/libloc_la-network-list.lo
  CC       src/libloc_la-resolv.lo
  CC       src/libloc_la-stringpool.lo
In function ‘loc_stringpool_new’:
src/stringpool.c:132:2: warning: leak of ‘<unknown>’ [CWE-401] [-Wanalyzer-malloc-leak]
  132 |  return r;
      |  ^~~~~~
  ‘loc_stringpool_new’: events 1-2
    |
    |  124 | LOC_EXPORT int loc_stringpool_new(struct loc_ctx* ctx, struct loc_stringpool** pool) {
    |      |                ^~~~~~~~~~~~~~~~~~
    |      |                |
    |      |                (1) entry to ‘loc_stringpool_new’
    |  125 |  int r = __loc_stringpool_new(ctx, pool, STRINGPOOL_DEFAULT);
    |      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |          |
    |      |          (2) calling ‘__loc_stringpool_new’ from ‘loc_stringpool_new’
    |
    +--> ‘__loc_stringpool_new’: events 3-5
           |
           |  108 | static int __loc_stringpool_new(struct loc_ctx* ctx, struct loc_stringpool** pool, enum loc_stringpool_mode mode) {
           |      |            ^~~~~~~~~~~~~~~~~~~~
           |      |            |
           |      |            (3) entry to ‘__loc_stringpool_new’
           |  109 |  struct loc_stringpool* p = calloc(1, sizeof(*p));
           |  110 |  if (!p)
           |      |     ~       
           |      |     |
           |      |     (4) following ‘false’ branch (when ‘p’ is non-NULL)...
           |......
           |  113 |  p->ctx = loc_ref(ctx);
           |      |  ~          
           |      |  |
           |      |  (5) ...to here
           |
    <------+
    |
  ‘loc_stringpool_new’: events 6-10
    |
    |  125 |  int r = __loc_stringpool_new(ctx, pool, STRINGPOOL_DEFAULT);
    |      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |          |
    |      |          (6) returning to ‘loc_stringpool_new’ from ‘__loc_stringpool_new’
    |  126 |  if (r)
    |      |     ~     
    |      |     |
    |      |     (7) following ‘false’ branch (when ‘r == 0’)...
    |......
    |  130 |  loc_stringpool_append(*pool, "");
    |      |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |  |
    |      |  (8) ...to here
    |      |  (9) state of ‘<unknown>’: ‘start’ -> ‘nonnull’ (origin: NULL)
    |      |  (10) calling ‘loc_stringpool_append’ from ‘loc_stringpool_new’
    |
    +--> ‘loc_stringpool_append’: events 11-14
           |
           |   83 | static off_t loc_stringpool_append(struct loc_stringpool* pool, const char* string) {
           |      |              ^~~~~~~~~~~~~~~~~~~~~
           |      |              |
           |      |              (11) entry to ‘loc_stringpool_append’
           |   84 |  if (!string || !*string)
           |      |     ~~~~~~~~~~~~~~~~~~~~
           |      |     |        |   |
           |      |     |        |   (13) ...to here
           |      |     |        (14) following ‘false’ branch...
           |      |     (12) following ‘false’ branch (when ‘string’ is non-NULL)...
           |
         ‘loc_stringpool_append’: event 15
           |
           |./src/loc/private.h:41:30:
           |   41 | #  define DEBUG(ctx, arg...) loc_log_null(ctx, ## arg)
           |      |                              ^~~~~~~~~~~~
           |      |                              |
           |      |                              (15) ...to here
src/stringpool.c:87:2: note: in expansion of macro ‘DEBUG’
           |   87 |  DEBUG(pool->ctx, "Appending '%s' to string pool at %p\n", string, pool);
           |      |  ^~~~~
           |
         ‘loc_stringpool_append’: event 16
           |
           |   90 |  int r = loc_stringpool_grow(pool, pool->length + strlen(string) + 1);
           |      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |          |
           |      |          (16) calling ‘loc_stringpool_grow’ from ‘loc_stringpool_append’
           |
           +--> ‘loc_stringpool_grow’: events 17-18
                  |
                  |   64 | static int loc_stringpool_grow(struct loc_stringpool* pool, size_t length) {
                  |      |            ^~~~~~~~~~~~~~~~~~~
                  |      |            |
                  |      |            (17) entry to ‘loc_stringpool_grow’
                  |......
                  |   72 |  if (!pool->data)
                  |      |     ~       
                  |      |     |
                  |      |     (18) following ‘true’ branch...
                  |
                ‘loc_stringpool_grow’: event 19
                  |
                  |cc1:
                  | (19): ...to here
                  |
           <------+
           |
         ‘loc_stringpool_append’: events 20-21
           |
           |   90 |  int r = loc_stringpool_grow(pool, pool->length + strlen(string) + 1);
           |      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |          |
           |      |          (20) returning to ‘loc_stringpool_append’ from ‘loc_stringpool_grow’
           |   91 |  if (r) {
           |      |     ~     
           |      |     |
           |      |     (21) following ‘true’ branch (when ‘r != 0’)...
           |
         ‘loc_stringpool_append’: event 22
           |
           |   92 |   errno = r;
           |      |   ^~~~~
           |      |   |
           |      |   (22) ...to here
           |
    <------+
    |
  ‘loc_stringpool_new’: events 23-24
    |
    |  130 |  loc_stringpool_append(*pool, "");
    |      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |  |
    |      |  (23) returning to ‘loc_stringpool_new’ from ‘loc_stringpool_append’
    |  131 | 
    |  132 |  return r;
    |      |  ~~~~~~
    |      |  |
    |      |  (24) ‘<unknown>’ leaks here
    |
In function ‘loc_stringpool_open’:
src/stringpool.c:163:6: warning: leak of ‘<unknown>’ [CWE-401] [-Wanalyzer-malloc-leak]
  163 |   if (r)
      |      ^
  ‘loc_stringpool_open’: events 1-2
    |
    |  154 | LOC_EXPORT int loc_stringpool_open(struct loc_ctx* ctx, struct loc_stringpool** pool,
    |      |                ^~~~~~~~~~~~~~~~~~~
    |      |                |
    |      |                (1) entry to ‘loc_stringpool_open’
    |  155 |   FILE* f, size_t length, off_t offset) {
    |  156 |  int r = __loc_stringpool_new(ctx, pool, STRINGPOOL_MMAP);
    |      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |          |
    |      |          (2) calling ‘__loc_stringpool_new’ from ‘loc_stringpool_open’
    |
    +--> ‘__loc_stringpool_new’: events 3-5
           |
           |  108 | static int __loc_stringpool_new(struct loc_ctx* ctx, struct loc_stringpool** pool, enum loc_stringpool_mode mode) {
           |      |            ^~~~~~~~~~~~~~~~~~~~
           |      |            |
           |      |            (3) entry to ‘__loc_stringpool_new’
           |  109 |  struct loc_stringpool* p = calloc(1, sizeof(*p));
           |  110 |  if (!p)
           |      |     ~       
           |      |     |
           |      |     (4) following ‘false’ branch (when ‘p’ is non-NULL)...
           |......
           |  113 |  p->ctx = loc_ref(ctx);
           |      |  ~          
           |      |  |
           |      |  (5) ...to here
           |
    <------+
    |
  ‘loc_stringpool_open’: events 6-12
    |
    |  156 |  int r = __loc_stringpool_new(ctx, pool, STRINGPOOL_MMAP);
    |      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |          |
    |      |          (6) returning to ‘loc_stringpool_open’ from ‘__loc_stringpool_new’
    |  157 |  if (r)
    |      |     ~     
    |      |     |
    |      |     (7) following ‘false’ branch (when ‘r == 0’)...
    |......
    |  161 |  if (length > 0) {
    |      |  ~~ ~     
    |      |  |  |
    |      |  |  (9) following ‘true’ branch (when ‘length != 0’)...
    |      |  (8) ...to here
    |  162 |   r = loc_stringpool_mmap(*pool, f, length, offset);
    |      |   ~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |   |   |
    |      |   |   (12) calling ‘loc_stringpool_mmap’ from ‘loc_stringpool_open’
    |      |   (10) ...to here
    |      |   (11) state of ‘<unknown>’: ‘start’ -> ‘nonnull’ (origin: NULL)
    |
    +--> ‘loc_stringpool_mmap’: events 13-14
           |
           |  135 | static int loc_stringpool_mmap(struct loc_stringpool* pool, FILE* f, size_t length, off_t offset) {
           |      |            ^~~~~~~~~~~~~~~~~~~
           |      |            |
           |      |            (13) entry to ‘loc_stringpool_mmap’
           |  136 |  if (pool->mode != STRINGPOOL_MMAP)
           |      |     ~       
           |      |     |
           |      |     (14) following ‘false’ branch...
           |
         ‘loc_stringpool_mmap’: event 15
           |
           |./src/loc/private.h:41:30:
           |   41 | #  define DEBUG(ctx, arg...) loc_log_null(ctx, ## arg)
           |      |                              ^~~~~~~~~~~~
           |      |                              |
           |      |                              (15) ...to here
src/stringpool.c:139:2: note: in expansion of macro ‘DEBUG’
           |  139 |  DEBUG(pool->ctx, "Reading string pool starting from %jd (%zu bytes)\n", (intmax_t)offset, length);
           |      |  ^~~~~
           |
         ‘loc_stringpool_mmap’: events 16-17
           |
           |  148 |  if (pool->data == MAP_FAILED)
           |      |     ^
           |      |     |
           |      |     (16) following ‘true’ branch...
           |  149 |   return -errno;
           |      |   ~~~~~~
           |      |   |
           |      |   (17) ...to here
           |
    <------+
    |
  ‘loc_stringpool_open’: events 18-19
    |
    |  162 |   r = loc_stringpool_mmap(*pool, f, length, offset);
    |      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |       |
    |      |       (18) returning to ‘loc_stringpool_open’ from ‘loc_stringpool_mmap’
    |  163 |   if (r)
    |      |      ~ 
    |      |      |
    |      |      (19) following ‘false’ branch (when ‘r == 0’)...
    |
  ‘loc_stringpool_open’: event 20
    |
    |cc1:
    | (20): ...to here
    |
  ‘loc_stringpool_open’: event 21
    |
    |  163 |   if (r)
    |      |      ^
    |      |      |
    |      |      (21) ‘<unknown>’ leaks here
    |
In function ‘loc_stringpool_get_next_offset’:
src/stringpool.c:212:18: warning: use of NULL ‘string’ where non-null expected [CWE-690] [-Wanalyzer-null-argument]
  212 |  return offset + strlen(string) + 1;
      |                  ^~~~~~~~~~~~~~
  ‘loc_stringpool_dump’: events 1-4
    |
    |  253 | LOC_EXPORT void loc_stringpool_dump(struct loc_stringpool* pool) {
    |      |                 ^~~~~~~~~~~~~~~~~~~
    |      |                 |
    |      |                 (1) entry to ‘loc_stringpool_dump’
    |......
    |  256 |  while (offset < pool->length) {
    |      |        ~         
    |      |        |
    |      |        (2) following ‘true’ branch...
    |  257 |   const char* string = loc_stringpool_get(pool, offset);
    |      |   ~~~~~                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |   |                    |
    |      |   (3) ...to here       (4) calling ‘loc_stringpool_get’ from ‘loc_stringpool_dump’
    |
    +--> ‘loc_stringpool_get’: events 5-9
           |
           |   58 |  if (offset < 0 || offset >= pool->length)
           |      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |     |           |                |
           |      |     |           |                (7) ...to here
           |      |     |           (8) following ‘false’ branch...
           |      |     (6) following ‘false’ branch (when ‘offset >= 0’)...
           |......
           |   61 |  return pool->data + offset;
           |      |  ~~~~~~                 
           |      |  |
           |      |  (9) ...to here
           |......
           |  215 | LOC_EXPORT const char* loc_stringpool_get(struct loc_stringpool* pool, off_t offset) {
           |      |                        ^~~~~~~~~~~~~~~~~~
           |      |                        |
           |      |                        (5) entry to ‘loc_stringpool_get’
           |
    <------+
    |
  ‘loc_stringpool_dump’: events 10-13
    |
    |  257 |   const char* string = loc_stringpool_get(pool, offset);
    |      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |                        |
    |      |                        (10) returning to ‘loc_stringpool_dump’ from ‘loc_stringpool_get’
    |  258 |   if (!string)
    |      |      ~                  
    |      |      |
    |      |      (11) following ‘false’ branch (when ‘string’ is non-NULL)...
    |......
    |  261 |   printf("%jd (%zu): %s\n", (intmax_t)offset, strlen(string), string);
    |      |   ~~~~~~                
    |      |   |
    |      |   (12) ...to here
    |  262 | 
    |  263 |   offset = loc_stringpool_get_next_offset(pool, offset);
    |      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |            |
    |      |            (13) calling ‘loc_stringpool_get_next_offset’ from ‘loc_stringpool_dump’
    |
    +--> ‘loc_stringpool_get_next_offset’: events 14-15
           |
           |  209 | static off_t loc_stringpool_get_next_offset(struct loc_stringpool* pool, off_t offset) {
           |      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |              |
           |      |              (14) entry to ‘loc_stringpool_get_next_offset’
           |  210 |  const char* string = loc_stringpool_get(pool, offset);
           |      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |                       |
           |      |                       (15) calling ‘loc_stringpool_get’ from ‘loc_stringpool_get_next_offset’
           |
           +--> ‘loc_stringpool_get’: events 16-21
                  |
                  |   58 |  if (offset < 0 || offset >= pool->length)
                  |      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  |      |     |           |                |
                  |      |     |           |                (18) ...to here
                  |      |     |           (19) following ‘true’ branch...
                  |      |     (17) following ‘false’ branch (when ‘offset >= 0’)...
                  |......
                  |  215 | LOC_EXPORT const char* loc_stringpool_get(struct loc_stringpool* pool, off_t offset) {
                  |      |                        ^~~~~~~~~~~~~~~~~~
                  |      |                        |
                  |      |                        (16) entry to ‘loc_stringpool_get’
                  |  216 |  return __loc_stringpool_get(pool, offset);
                  |      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  |      |         |
                  |      |         (20) ...to here
                  |      |         (21) ‘<return-value>’ is NULL
                  |
           <------+
           |
         ‘loc_stringpool_get_next_offset’: events 22-23
           |
           |  210 |  const char* string = loc_stringpool_get(pool, offset);
           |      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |                       |
           |      |                       (22) returning to ‘loc_stringpool_get_next_offset’ from ‘loc_stringpool_get’
           |  211 | 
           |  212 |  return offset + strlen(string) + 1;
           |      |                  ~~~~~~~~~~~~~~
           |      |                  |
           |      |                  (23) argument 1 (‘string’) NULL where non-null expected
           |
In file included from src/stringpool.c:21:
/usr/include/string.h:385:15: note: argument 1 of ‘strlen’ must be non-null
  385 | extern size_t strlen (const char *__s)
      |               ^~~~~~
  CC       src/libloc_la-writer.lo
  CCLD     src/libloc.la
  CC       src/python/_location_la-locationmodule.lo
  CC       src/python/_location_la-as.lo
  CC       src/python/_location_la-country.lo
  CC       src/python/_location_la-database.lo
  CC       src/python/_location_la-network.lo
  CC       src/python/_location_la-writer.lo
  CCLD     src/python/_location.la
  GEN      src/python/location
  GEN      src/python/location-importer
  ASCIIDOC man/location.xml
  XSLT     man/location.8
  GEN      src/libloc.pc
cd ./src/perl && /usr/bin/perl Makefile.PL INSTALLDIRS=vendor \
	INC="-I/root/libloc/src" LIBS="-L/root/libloc/src/.libs -lloc"
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Location
Writing MYMETA.yml and MYMETA.json
cd ./src/perl && make LD_RUN_PATH=
cp lib/Location.pm blib/lib/Location.pm
Running Mkbootstrap for Location ()
chmod 644 "Location.bs"
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Location.bs blib/arch/auto/Location/Location.bs 644
"/usr/bin/perl" "/usr/share/perl/5.32/ExtUtils/xsubpp"  -typemap '/usr/share/perl/5.32/ExtUtils/typemap' -typemap '/root/libloc/src/perl/typemap'  Location.xs > Location.xsc
Please specify prototyping behavior for Location.xs (see perlxs manual)
mv Location.xsc Location.c
x86_64-linux-gnu-gcc -c  -I/root/libloc/src -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g   -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" -fPIC "-I/usr/lib/x86_64-linux-gnu/perl/5.32/CORE"   Location.c
rm -f blib/arch/auto/Location/Location.so
LD_RUN_PATH="" x86_64-linux-gnu-gcc  -shared -L/usr/local/lib -fstack-protector-strong  Location.o  -o blib/arch/auto/Location/Location.so  \
   -L/root/libloc/src/.libs -lloc   \
  
chmod 755 blib/arch/auto/Location/Location.so
Manifying 1 pod document
rm man/location.xml
Making all in po
make[2]: Nothing to be done for 'all'.
  

Patch

diff --git a/Makefile.am b/Makefile.am
index 0c2f78c..7782354 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,11 +19,12 @@  AM_CPPFLAGS = \
 	-I${top_srcdir}/src
 
 AM_CFLAGS = ${warn_CFLAGS} \
+	${asan_CFLAGS} \
 	${my_CFLAGS} \
 	-ffunction-sections \
 	-fdata-sections
 
-AM_LDFLAGS =
+AM_LDFLAGS = ${asan_LDFLAGS}
 
 # leaving a space here to work around automake's conditionals
  ifeq ($(OS),Darwin)
diff --git a/configure.ac b/configure.ac
index dd1ca64..6a4ee0c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -104,6 +104,32 @@  AS_IF([test "x$more_warnings" = "xyes"],[
 
 AC_SUBST([warn_CFLAGS])
 
+# - asan -----------------------------------------------------------------------
+
+asan_CFLAGS=""
+asan_LDFLAGS=""
+
+AC_ARG_ENABLE([asan],
+        AS_HELP_STRING([--enable-asan], [enable the address sanitizer @<:@default=disabled@:>@]),
+        [asan=yes], [asan=no])
+AS_IF([test "x$asan" = "xyes"],[
+	asan_CFLAGS+="\
+	-g \
+	-fsanitize=address \
+	-fno-omit-frame-pointer \
+	-fsanitize-recover=address \
+	"
+
+	asan_LDFLAGS+="\
+	-fsanitize=address \
+	"
+])
+
+AC_SUBST([asan_CFLAGS])
+AC_SUBST([asan_LDFLAGS])
+
+# ------------------------------------------------------------------------------
+
 my_CFLAGS="\
 -Wall \
 -Wchar-subscripts \