Stuff that came out of valgrind on FreeBSD 12

This commit is contained in:
Willem Toorop 2019-12-20 11:09:24 +00:00
parent 8da6fdb442
commit 4fdf3a8b2a
15 changed files with 313 additions and 19 deletions

View File

@ -1228,7 +1228,7 @@ void _getdns_start_fetching_ta(
{
getdns_return_t r;
size_t scheduled;
char tas_hostname[256];
char tas_hostname[256] = "";
const char *verify_CA;
const char *verify_email;

View File

@ -3486,7 +3486,7 @@ static getdns_return_t
ub_setup_recursing(struct ub_ctx *ctx, getdns_context *context)
{
_getdns_rr_iter rr_spc, *rr;
char ta_str[8192];
char ta_str[8192] = "";
int r;
if ((r = ub_ctx_set_fwd(ctx, NULL))) {

View File

@ -1356,7 +1356,7 @@ static int _jsmn_get_int(const char *js, jsmntok_t *t, uint32_t *value)
static int _jsmn_get_const(const char *js, jsmntok_t *t, uint32_t *value)
{
char value_str[80];
char value_str[80] = "";
int size = t->end - t->start;
if (size <= 0 || size >= (int)sizeof(value_str))

View File

@ -83,7 +83,7 @@ static char *_json_ptr_first(const struct mem_funcs *mf,
static struct getdns_dict_item *
_find_dict_item(const getdns_dict *dict, const char *jptr)
{
char first_spc[1024], *first;
char first_spc[1024] = "", *first;
struct getdns_dict_item *d;
first = _json_ptr_first(&dict->mf, jptr,

View File

@ -737,7 +737,7 @@ gldns_str2wire_rr_buf_internal(const char* str, uint8_t* rr, size_t* len,
{
int status;
int not_there = 0;
char token[GLDNS_MAX_RDFLEN+1];
char token[GLDNS_MAX_RDFLEN+1] = "";
uint32_t ttl = 0;
uint16_t tp = 0, cl = 0;
size_t ddlen = 0;

View File

@ -0,0 +1,57 @@
#! /usr/local/bin/gawk -f
# A script to extract the actual suppression info from the output of (for example) valgrind --leak-check=full --show-reachable=yes --error-limit=no --gen-suppressions=all ./minimal
# The desired bits are between ^{ and ^} (including the braces themselves).
# The combined output should either be appended to /usr/lib/valgrind/default.supp, or placed in a .supp of its own
# If the latter, either tell valgrind about it each time with --suppressions=<filename>, or add that line to ~/.valgrindrc
# NB This script uses the |& operator, which I believe is gawk-specific. In case of failure, check that you're using gawk rather than some other awk
# The script looks for suppressions. When it finds one it stores it temporarily in an array,
# and also feeds it line by line to the external app 'md5sum' which generates a unique checksum for it.
# The checksum is used as an index in a different array. If an item with that index already exists the suppression must be a duplicate and is discarded.
BEGIN { suppression=0; md5sum = "md5" }
# If the line begins with '{', it's the start of a supression; so set the var and initialise things
/^{/ {
suppression=1; i=0; next
}
# If the line begins with '}' its the end of a suppression
/^}/ {
if (suppression)
{ suppression=0;
close(md5sum, "to") # We've finished sending data to md5sum, so close that part of the pipe
ProcessInput() # Do the slightly-complicated stuff in functions
delete supparray # We don't want subsequent suppressions to append to it!
}
}
# Otherwise, it's a normal line. If we're inside a supression, store it, and pipe it to md5sum. Otherwise it's cruft, so ignore it
{ if (suppression)
{
supparray[++i] = $0
print |& md5sum
}
}
function ProcessInput()
{
# Pipe the result from md5sum, then close it
md5sum |& getline result
close(md5sum)
# gawk can't cope with enormous ints like $result would be, so stringify it first by prefixing a definite string
resultstring = "prefix"result
if (! (resultstring in chksum_array) )
{ chksum_array[resultstring] = 0; # This checksum hasn't been seen before, so add it to the array
OutputSuppression() # and output the contents of the suppression
}
}
function OutputSuppression()
{
# A suppression is surrounded by '{' and '}'. Its data was stored line by line in the array
print "{"
for (n=1; n <= i; ++n)
{ print supparray[n] }
print "}"
}

View File

@ -16,3 +16,65 @@
fun:pthread_attr_init
obj:/usr/local/lib/libunbound.so.8.1.5
}
{
<insert_a_suppression_name_here>
Memcheck:Cond
obj:/lib/libc.so.7
obj:/lib/libc.so.7
obj:*
obj:/lib/libc.so.7
obj:*
obj:/lib/libc.so.7
obj:/lib/libc.so.7
obj:/lib/libc.so.7
obj:/root/getdns/tests/build/getdns_query
obj:/lib/libc.so.7
}
{
<insert_a_suppression_name_here>
Memcheck:Cond
obj:/lib/libc.so.7
obj:*
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
fun:_getdns_submit_netreq
fun:getdns_general_ns
}
{
<insert_a_suppression_name_here>
Memcheck:Cond
obj:/lib/libc.so.7
obj:*
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
fun:_getdns_submit_netreq
}
{
<insert_a_suppression_name_here>
Memcheck:Cond
obj:/lib/libc.so.7
obj:*
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
}

View File

@ -4,6 +4,15 @@
# use .tpkg.var.test for in test variable passing
[ -f .tpkg.var.test ] && source .tpkg.var.test
## To add suppressions:
##
#
# valgrind -v --log-file=valgrind.log --suppressions="${TPKG_NAME}.supp" --leak-check=full --error-exitcode=1 --track-origins=yes --gen-suppressions=all "${GETDNS_QUERY}" -F "${TPKG_NAME}.queries" -f "${TPKG_NAME}.ds" +dnssec_return_validation_chain
# ./${PKG_NAME}.parse_valgrind_suppressions.sh > new_supps
# cat ${PKG_NAME}.supp new_supps > tmp_supps
# mv tmp_supps ${PKG_NAME}.supp
#
(
if ! valgrind -v --log-file=valgrind.log --suppressions="${TPKG_NAME}.supp" --leak-check=full --error-exitcode=1 --track-origins=yes "${GETDNS_QUERY}" -F "${TPKG_NAME}.queries" -f "${TPKG_NAME}.ds" +dnssec_return_validation_chain
then

View File

@ -0,0 +1,57 @@
#! /usr/local/bin/gawk -f
# A script to extract the actual suppression info from the output of (for example) valgrind --leak-check=full --show-reachable=yes --error-limit=no --gen-suppressions=all ./minimal
# The desired bits are between ^{ and ^} (including the braces themselves).
# The combined output should either be appended to /usr/lib/valgrind/default.supp, or placed in a .supp of its own
# If the latter, either tell valgrind about it each time with --suppressions=<filename>, or add that line to ~/.valgrindrc
# NB This script uses the |& operator, which I believe is gawk-specific. In case of failure, check that you're using gawk rather than some other awk
# The script looks for suppressions. When it finds one it stores it temporarily in an array,
# and also feeds it line by line to the external app 'md5sum' which generates a unique checksum for it.
# The checksum is used as an index in a different array. If an item with that index already exists the suppression must be a duplicate and is discarded.
BEGIN { suppression=0; md5sum = "md5" }
# If the line begins with '{', it's the start of a supression; so set the var and initialise things
/^{/ {
suppression=1; i=0; next
}
# If the line begins with '}' its the end of a suppression
/^}/ {
if (suppression)
{ suppression=0;
close(md5sum, "to") # We've finished sending data to md5sum, so close that part of the pipe
ProcessInput() # Do the slightly-complicated stuff in functions
delete supparray # We don't want subsequent suppressions to append to it!
}
}
# Otherwise, it's a normal line. If we're inside a supression, store it, and pipe it to md5sum. Otherwise it's cruft, so ignore it
{ if (suppression)
{
supparray[++i] = $0
print |& md5sum
}
}
function ProcessInput()
{
# Pipe the result from md5sum, then close it
md5sum |& getline result
close(md5sum)
# gawk can't cope with enormous ints like $result would be, so stringify it first by prefixing a definite string
resultstring = "prefix"result
if (! (resultstring in chksum_array) )
{ chksum_array[resultstring] = 0; # This checksum hasn't been seen before, so add it to the array
OutputSuppression() # and output the contents of the suppression
}
}
function OutputSuppression()
{
# A suppression is surrounded by '{' and '}'. Its data was stored line by line in the array
print "{"
for (n=1; n <= i; ++n)
{ print supparray[n] }
print "}"
}

View File

@ -0,0 +1,7 @@
NS .
-A getdnsapi.net
qwerlkjhasdfpuiqwyerm.1234kjhrqwersv.com
-G TXT bogus.nlnetlabs.nl
-H 8.8.8.8
-H 2a04:b900:0:100::37
-A _acme-challenge.getdnsapi.net

View File

@ -0,0 +1,102 @@
{
<insert_a_suppression_name_here>
Memcheck:Cond
obj:/lib/libc.so.7
obj:/lib/libc.so.7
obj:*
obj:/lib/libc.so.7
obj:*
obj:/lib/libc.so.7
obj:/lib/libc.so.7
obj:/lib/libc.so.7
obj:/root/getdns/tests/build-stub-only/getdns_query
obj:/lib/libc.so.7
}
{
<insert_a_suppression_name_here>
Memcheck:Cond
obj:/lib/libc.so.7
obj:*
obj:/lib/libc.so.7
}
{
<insert_a_suppression_name_here>
Memcheck:Cond
obj:/lib/libc.so.7
obj:*
fun:strcpytrunc
fun:ta_iter_next
fun:ta_iter_init
fun:_getdns_parse_xml_trust_anchors_buf
fun:_getdns_context_equip_with_anchor
fun:getdns_general_ns
fun:_getdns_general_loop
fun:getdns_general_sync
fun:do_the_call
fun:read_line_cb
}
{
<insert_a_suppression_name_here>
Memcheck:Cond
obj:/lib/libc.so.7
obj:*
fun:strcpytrunc
fun:ta_iter_next
fun:_getdns_parse_xml_trust_anchors_buf
fun:_getdns_context_equip_with_anchor
fun:getdns_general_ns
fun:_getdns_general_loop
fun:getdns_general_sync
fun:do_the_call
fun:read_line_cb
fun:poll_read_cb
}
{
<insert_a_suppression_name_here>
Memcheck:Cond
obj:/lib/libc.so.7
obj:*
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
fun:_getdns_submit_netreq
fun:getdns_general_ns
}
{
<insert_a_suppression_name_here>
Memcheck:Cond
obj:/lib/libc.so.7
obj:*
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
fun:_getdns_submit_netreq
}
{
<insert_a_suppression_name_here>
Memcheck:Cond
obj:/lib/libc.so.7
obj:*
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
obj:/usr/local/lib/libunbound.so.8.1.5
}

View File

@ -4,17 +4,17 @@
# use .tpkg.var.test for in test variable passing
[ -f .tpkg.var.test ] && source .tpkg.var.test
cat >queries <<EOT
NS .
-A getdnsapi.net
qwerlkjhasdfpuiqwyerm.1234kjhrqwersv.com
-G TXT bogus.nlnetlabs.nl
-H 8.8.8.8
-H 2a04:b900:0:100::37
-A _acme-challenge.getdnsapi.net
EOT
## To add suppressions:
##
#
# valgrind -v --log-file=valgrind.log --suppressions="${TPKG_NAME}.supp" --leak-check=full --error-exitcode=1 --track-origins=yes --gen-suppressions=all "${GETDNS_STUB_QUERY}" -F "${TPKG_NAME}.queries" +dnssec_return_validation_chain
# ./${TPKG_NAME}.parse_valgrind_suppressions.sh < valgrind.log > new_supps
# cat ${TPKG_NAME}.supp new_supps > tmp_supps
# mv tmp_supps ${TPKG_NAME}.supp
#
(
if ! valgrind -v --log-file=valgrind.log --leak-check=full --error-exitcode=1 --track-origins=yes "${GETDNS_STUB_QUERY}" -F queries -f "${TPKG_NAME}.ds" +dnssec_return_validation_chain
if ! valgrind -v --log-file=valgrind.log --suppressions="${TPKG_NAME}.supp" --leak-check=full --error-exitcode=1 --track-origins=yes "${GETDNS_STUB_QUERY}" -F "${TPKG_NAME}.queries" +dnssec_return_validation_chain
then
exit 1
fi

View File

@ -92,8 +92,8 @@ int main(int argc, char **argv)
uint32_t port1 = 18000;
uint32_t port2 = 18000;
getdns_return_t r;
char listenliststr[1024];
char listendictstr[1024];
char listenliststr[1024] = "";
char listendictstr[1024] = "";
if (argc != 2) {
fprintf(stderr, "usage: %s <localhost ipv4>\n", argv[0]);

View File

@ -114,7 +114,7 @@ int main(int argc, char **argv)
getdns_dict *address = NULL;
uint32_t port = 18000;
getdns_return_t r;
char listenliststr[1024];
char listenliststr[1024] = "";
if (argc != 2) {
fprintf(stderr, "usage: %s <localhost ipv4>\n", argv[0]);

View File

@ -119,7 +119,7 @@ int main(int argc, char **argv)
getdns_dict *address = NULL;
uint32_t port = 18000;
getdns_return_t r;
char listenliststr[1024];
char listenliststr[1024] = "";
if (argc != 2) {
fprintf(stderr, "usage: %s <localhost ipv4>\n", argv[0]);