[PATCH] Make samba build with address sanitizer configured.

Gary Lockyer gary at catalyst.net.nz
Mon May 6 02:51:34 UTC 2019


Two patches that allow "make" and "make test" to run when Address
Sanitizer is configured.

CI: https://gitlab.com/samba-team/devel/samba/pipelines/59874413
MR: https://gitlab.com/samba-team/samba/merge_requests/419

Review appreciated

Ngā mihi
Gary
-------------- next part --------------
From ff3173de3a7d7a346f4ac5756442b70d07f95a64 Mon Sep 17 00:00:00 2001
From: Gary Lockyer <gary at catalyst.net.nz>
Date: Mon, 6 May 2019 13:12:33 +1200
Subject: [PATCH 1/2] s4 heimdal_build: disable leak checks for asn1 compiler

Disable Address Sanitizer leak checking for the heimdal asn1 compiler, this
allows a samba build with Address Sanitizer enabled.

Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
---
 source4/heimdal_build/wscript_build | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/source4/heimdal_build/wscript_build b/source4/heimdal_build/wscript_build
index 871db6b37fb..bedc130e07a 100644
--- a/source4/heimdal_build/wscript_build
+++ b/source4/heimdal_build/wscript_build
@@ -4,6 +4,7 @@ import os
 from waflib import Context
 from samba_utils import SET_TARGET_TYPE
 from samba_autoconf import CURRENT_CFLAGS
+from samba_utils import LOAD_ENVIRONMENT
 
 def to_list(str):
     '''Split a list, preserving quoted strings and existing lists'''
@@ -57,7 +58,15 @@ def HEIMDAL_ASN1(name, source,
     # source file. Note that in the case of a option_file, we have more than
     # one source file
     cd_rule = 'cd "${TGT[0].parent.abspath(env)}"'
-    asn1_rule = cd_rule + ' && "${ASN1_COMPILE}" ${OPTION_FILE} ${ASN1OPTIONS} --one-code-file "${SRC[0].abspath(env)}" ${ASN1NAME}'
+    env = LOAD_ENVIRONMENT()
+    if env.ADDRESS_SANITIZER:
+        # If address sanitizer is enabled, we need to suppress leak checking
+        # in the asn1 tool.
+        no_leak_check = " && export ASAN_OPTIONS=detect_leaks=0"
+    else:
+        no_leak_check = ""
+
+    asn1_rule = cd_rule + no_leak_check + ' && "${ASN1_COMPILE}" ${OPTION_FILE} ${ASN1OPTIONS} --one-code-file "${SRC[0].abspath(env)}" ${ASN1NAME}'
 
     source = to_list(source)
 
-- 
2.18.1


From e8c3bb100c4d10be453680b63d30154c7c92681b Mon Sep 17 00:00:00 2001
From: Gary Lockyer <gary at catalyst.net.nz>
Date: Mon, 6 May 2019 13:14:37 +1200
Subject: [PATCH 2/2] selftest: Utils.cmd_output returns byte string

Convert the returned byte string into a string.

Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
---
 selftest/wscript | 1 +
 1 file changed, 1 insertion(+)

diff --git a/selftest/wscript b/selftest/wscript
index 2fd38e20a4a..44455480eb1 100644
--- a/selftest/wscript
+++ b/selftest/wscript
@@ -276,6 +276,7 @@ def cmd_testonly(opt):
         # We try to find the correct libasan automatically
         libasan = Utils.cmd_output('ldd bin/texpect | grep libasan| cut -f 3 -d \ ',
                                    silent=True).strip()
+        libasan = libasan.decode('utf8')
 
         # Have the selftest.pl LD_PRELOAD libasan in the right spot
         env.OPTIONS += " --asan_so_path=" + libasan
-- 
2.18.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20190506/9a687df0/signature.sig>


More information about the samba-technical mailing list