From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46288) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WN4pt-0002OX-L9 for qemu-devel@nongnu.org; Mon, 10 Mar 2014 14:22:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WN4po-0004dI-6t for qemu-devel@nongnu.org; Mon, 10 Mar 2014 14:22:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64823) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WN4pn-0004d3-UR for qemu-devel@nongnu.org; Mon, 10 Mar 2014 14:21:56 -0400 From: Markus Armbruster References: <87txb69rd9.fsf@blackfin.pond.sub.org> <87eh2a89ao.fsf@blackfin.pond.sub.org> Date: Mon, 10 Mar 2014 19:21:51 +0100 In-Reply-To: (Peter Maydell's message of "Mon, 10 Mar 2014 13:41:31 +0000") Message-ID: <87iorl29ts.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] test-qapi-visit causes clang -fsanitize=undefined warning List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: QEMU Developers , Luiz Capitulino Peter Maydell writes: > On 10 March 2014 13:36, Markus Armbruster wrote: >> Peter Maydell writes: >> Turns out my clang installation doesn't support -fsanitize=undefined: it >> lacks libclang_rt.san-x86_64.a. >> >> Test works fine without -fsanitize=undefined. I set a breakpoint on >> visit_type_UserDefA_fields, and there's no null pointer to be found. > > Yes, there is. This is gdb on a gcc-compiled version of > the test: > > /visitor/input-strict/fail/union-flat: > Breakpoint 1, visit_type_UserDefA_fields (m=0x5555557a8ed0, > obj=0x5555557a8d88, errp=0x7fffffffdfb0) > at tests/test-qapi-visit.c:460 > 460 { > (gdb) print *obj > $3 = (UserDefA *) 0x0 > (gdb) bt > #0 visit_type_UserDefA_fields (m=0x5555557a8ed0, obj=0x5555557a8d88, > errp=0x7fffffffdfb0) > at tests/test-qapi-visit.c:460 > #1 0x000055555555b2a2 in visit_type_UserDefFlatUnion > (m=0x5555557a8ed0, obj=0x7fffffffdfd8, name=0x0, errp=0x0) > at tests/test-qapi-visit.c:654 > #2 0x0000555555558c0b in qapi_free_UserDefFlatUnion > (obj=0x5555557a8d80) at tests/test-qapi-types.c:368 > #3 0x000055555555cc47 in test_validate_fail_union_flat > (data=0x5555557a8de0, unused=0x7fffffffe3f0) > at > /home/petmay01/linaro/qemu-from-laptop/qemu/tests/test-qmp-input-strict.c:241 > > *obj is NULL, which is what clang is complaining about. I think what happens here is the visitor fails half-way through constructing the type, and returns a UserDefFlatUnion with kind USER_DEF_UNION_KIND_A and data.a null, violating the data type's invariant. We either have to relax the invariant, or fix the error paths. I'm looking into the latter.