[ovs-dev] [PATCH] treewide: undefined behavior, passing null in nonnull parameters

Lance Richardson lrichard at redhat.com
Tue Jun 13 17:08:52 UTC 2017


> From: "Lance Richardson" <lrichard at redhat.com>
> To: dev at openvswitch.org
> Sent: Tuesday, 13 June, 2017 12:57:38 PM
> Subject: [ovs-dev] [PATCH] treewide: undefined behavior,	passing null in nonnull parameters
> 
> Eliminate a number of instances of undefined behavior related to
> passing NULL in parameters having "nonnull" annotations.
> 
> Found with gcc's undefined behavior sanitizer.
> 
> Signed-off-by: Lance Richardson <lrichard at redhat.com>
> ---

This patch addresses all ubsan errors of the "null vs. nonnull" flavor.
The remaining errors are:

$ grep runtime tests/testsuite.dir/*/testsuite.log
tests/testsuite.dir/0044/testsuite.log:+tests/test-hash.c:59:40: runtime error: shift exponent 64 is too large for 64-bit type 'long unsigned int'
tests/testsuite.dir/0057/testsuite.log:+tests/test-util.c:88:23: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
tests/testsuite.dir/0062/testsuite.log:+tests/test-util.c:49:29: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
tests/testsuite.dir/0062/testsuite.log:+tests/test-util.c:52:30: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
tests/testsuite.dir/0062/testsuite.log:+tests/test-util.c:52:42: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
tests/testsuite.dir/0062/testsuite.log:+tests/test-util.c:52:48: runtime error: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
tests/testsuite.dir/0062/testsuite.log:+tests/test-util.c:55:50: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
tests/testsuite.dir/0062/testsuite.log:+tests/test-util.c:55:67: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
tests/testsuite.dir/0062/testsuite.log:+tests/test-util.c:55:56: runtime error: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
tests/testsuite.dir/0432/testsuite.log:+lib/odp-util.c:5440:24: runtime error: load of misaligned address 0x000001d91f7c for type 'const union ovs_u128', which requires 8 byte alignment
tests/testsuite.dir/0435/testsuite.log:+lib/odp-util.c:511:65: runtime error: member access within misaligned address 0x0000019aa9b2 for type 'const struct ip6_hdr', which requires 4 byte alignment
tests/testsuite.dir/0435/testsuite.log:+lib/odp-util.c:511:24: runtime error: member access within misaligned address 0x0000019aa9b2 for type 'const struct ip6_hdr', which requires 4 byte alignment
tests/testsuite.dir/0435/testsuite.log:+lib/odp-util.c:510:68: runtime error: member access within misaligned address 0x0000019aa9b2 for type 'const struct ip6_hdr', which requires 4 byte alignment
tests/testsuite.dir/0435/testsuite.log:+lib/odp-util.c:510:23: runtime error: member access within misaligned address 0x0000019aa9b2 for type 'const struct ip6_hdr', which requires 4 byte alignment

Running the undefined behavior sanitizer is a matter of essentially:

   ./configure CFLAGS=-fsanitize=undefined
   make check

Possibly requiring either:

   yum install libubsan
or
   apt-get install libubsan0



More information about the dev mailing list