diff --git a/bin/dnssec/dnssec-cds.c b/bin/dnssec/dnssec-cds.c index 59aa45ee5f..0ef524a7e9 100644 --- a/bin/dnssec/dnssec-cds.c +++ b/bin/dnssec/dnssec-cds.c @@ -788,6 +788,8 @@ ds_from_cds(dns_rdatalist_t *dslist, isc_buffer_t *buf, dns_rdata_t *cds) { dns_rdata_ds_t ds; dns_rdata_t *rdata; + REQUIRE(buf != NULL); + rdata = rdata_get(); result = dns_rdata_tostruct(cds, &ds, NULL); @@ -807,6 +809,8 @@ ds_from_cdnskey(dns_rdatalist_t *dslist, isc_buffer_t *buf, isc_result_t result; unsigned i, n; + REQUIRE(buf != NULL); + n = sizeof(dtype)/sizeof(dtype[0]); for (i = 0; i < n; i++) { if (dtype[i] != 0) { diff --git a/bin/named/main.c b/bin/named/main.c index e4e4d81261..afdb25cae8 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -1229,6 +1229,7 @@ setup(void) { #endif named_server_create(named_g_mctx, &named_g_server); + ENSURE(named_g_server != NULL); sctx = named_g_server->sctx; /* diff --git a/bin/named/unix/os.c b/bin/named/unix/os.c index b1ac3b7773..c3b0bbee13 100644 --- a/bin/named/unix/os.c +++ b/bin/named/unix/os.c @@ -842,7 +842,7 @@ named_os_shutdownmsg(char *command, isc_buffer_t *text) { /* Skip the command name. */ - if ((ptr = strtok_r(command, " \t", &last)) == NULL) { + if (strtok_r(command, " \t", &last) == NULL) { return; } diff --git a/lib/isc/tests/timer_test.c b/lib/isc/tests/timer_test.c index 92f5b82489..128ce76b93 100644 --- a/lib/isc/tests/timer_test.c +++ b/lib/isc/tests/timer_test.c @@ -13,6 +13,7 @@ #if HAVE_CMOCKA +#include #include #include #include diff --git a/util/copyrights b/util/copyrights index b762dbe39a..56c8b2f527 100644 --- a/util/copyrights +++ b/util/copyrights @@ -2642,6 +2642,7 @@ ./util/nanny.pl PERL 2000,2001,2004,2007,2012,2016,2018,2019,2020 ./util/new-func PERL 2005,2007,2012,2016,2018,2019,2020 ./util/nt-kit SH 1999,2000,2001,2004,2007,2012,2016,2018,2019,2020 +./util/parse_tsan.py PYTHON-BIN 2020 ./util/spacewhack.pl PERL 2000,2001,2004,2007,2012,2016,2018,2019,2020 ./util/tabify-changes SH 2004,2007,2012,2016,2018,2019,2020 ./util/update-drafts.pl PERL 2000,2001,2004,2007,2012,2016,2018,2019,2020 diff --git a/util/parse_tsan.py b/util/parse_tsan.py new file mode 100755 index 0000000000..6e4e478995 --- /dev/null +++ b/util/parse_tsan.py @@ -0,0 +1,112 @@ +#!/usr/bin/env python3 +############################################################################ +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. +############################################################################ + +import sys, os, os.path, re +from hashlib import sha256 + +class State: + inside = False + block = "" + last_line = None + + mutexes = {} + m_index = 1 + threads = {} + t_index = 1 + pointers = {} + p_index = 1 + + def init(self): + self.reset() + + def reset(self): + self.inside = False + self.block = "" + + self.mutexes = {} + self.threads = {} + self.pointers = {} + self.pointers["0x000000000000"] = 0 + + self.m_index = 1 + self.t_index = 1 + self.p_index = 1 + +top = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + +out = os.path.join(top, "tsan") + +if not os.path.isdir(out): + os.mkdir(out) + +# Regular Expressions +mutex = re.compile(r"M\d+") +thread = re.compile(r"T\d+") +stack = re.compile(r"\s\(\S+\+0x\S+\)") +pointer = re.compile(r"0x[0-9a-f]+") +pid = re.compile(r"\(pid=\d+,?\)") +tid = re.compile(r"tid=\d+,?\s*") +worker = re.compile(r"\s+'(isc-worker|isc-net-)\d+'") +path = re.compile(top + "/") + +s = State() + + +with open(sys.argv[1], "r", encoding='utf-8') as f: + lines = f.readlines() + for line in lines: + if line == "==================\n": + if not s.inside: + s.inside = True + else: + dname = os.path.join(out, sha256(s.last_line.encode('utf-8')).hexdigest()) + if not os.path.isdir(dname): + os.mkdir(dname) + fname = os.path.join(dname, sha256(s.block.encode('utf-8')).hexdigest() + ".tsan") + if not os.path.isfile(fname): + with open(fname, "w", encoding='utf-8') as w: + w.write(s.block) + s.reset() + else: + for m in mutex.finditer(line): + k = m.group() + if k not in s.mutexes: + s.mutexes[k] = s.m_index + s.m_index += 1 + for m in thread.finditer(line): + k = m.group() + if k not in s.threads: + s.threads[k] = s.t_index + s.t_index += 1 + for m in pointer.finditer(line): + k = m.group() + if k not in s.pointers: + s.pointers[k] = s.p_index + s.p_index += 1 + for k, v in s.mutexes.items(): + r = re.compile(k) + line = r.sub("M%s" % v, line) + for k, v in s.threads.items(): + r = re.compile(k) + line = r.sub("T%s" % v, line) + for k, v in s.pointers.items(): + r = re.compile(k) + line = r.sub("0x%s" % str(v).zfill(12), line) + + line = stack.sub("", line) + line = pid.sub("", line) + line = tid.sub("", line) + line = worker.sub("", line) + line = path.sub("", line) + + s.block += line + s.last_line = line