[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] Three runtime errors in tests with UBSAN
From: |
Christian Grothoff |
Subject: |
Re: [libmicrohttpd] Three runtime errors in tests with UBSAN |
Date: |
Fri, 2 Mar 2018 22:07:03 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
On 02/27/2018 10:39 AM, Tim Rühsen wrote:
> $ CC=gcc CFLAGS="-O0 -g -ggdb3 -fno-omit-frame-pointer
> -fsanitize=undefined" ./configure
>
> $ make clean
> $ make check
> $ grep runtime src/*/*.log
>
> src/microhttpd/test_upgrade.log:test_upgrade.c:1075:32: runtime error:
> member access within misaligned address 0x560144586014 for type 'const
> union MHD_DaemonInfo', which requires 8 byte alignment
>
> src/microhttpd/test_upgrade_tls.log:test_upgrade.c:1075:32: runtime
> error: member access within misaligned address 0x55cea9a95014 for type
> 'const union MHD_DaemonInfo', which requires 8 byte alignment
I'm not sure I agree with these two, as while we return a 'union' with
an 8-byte alignment, the only valid *field* we return is 16-bit, and the
union overall is read-only. So reading the 16-bit field should be
perfectly safe from an alignment perspective (it is 16-bit aligned), and
everything else is a really bad idea (TM) anyway, as it would read garbage.
We could theoretically fix this, but to avoid ABI breakage this would
require using more memory (effectively reserving a fresh union for each
possible return case) and I do not see how this would gain anything for
anyone except making the sanitizer happy.
A better solution is of course the upcoming microhttpd2-API, which
avoids this issue entirely (by not returning a union).
For now, I've just hacked the testcase to memcpy() the port, which
doesn't actually improve the code but eliminates the warning. 8-)
> src/testcurl/test_put_chunked.log:test_put_chunked.c:107:16: runtime
> error: null pointer passed as argument 1, which is declared to never be null
Fixed.
signature.asc
Description: OpenPGP digital signature
- Re: [libmicrohttpd] Three runtime errors in tests with UBSAN,
Christian Grothoff <=