From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y3YiF-0006Yr-Ej for qemu-devel@nongnu.org; Tue, 23 Dec 2014 18:18:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y3Yi9-00012p-9T for qemu-devel@nongnu.org; Tue, 23 Dec 2014 18:17:59 -0500 Received: from mail-la0-f52.google.com ([209.85.215.52]:43604) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y3Yi8-00012i-UN for qemu-devel@nongnu.org; Tue, 23 Dec 2014 18:17:53 -0500 Received: by mail-la0-f52.google.com with SMTP id hs14so6348170lab.11 for ; Tue, 23 Dec 2014 15:17:52 -0800 (PST) MIME-Version: 1.0 From: Peter Maydell Date: Tue, 23 Dec 2014 23:17:31 +0000 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: [Qemu-devel] clang -fsanitize=undefined warnings in the string visitors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: QEMU Developers Cc: Paolo Bonzini , Michael Roth , Luiz Capitulino If you do a clang build with -fsanitize=undefined, then you get some sanitizer errors in make check: TEST: tests/test-string-output-visitor... (pid=31713) /string-visitor/output/int: OK /string-visitor/output/int: OK /string-visitor/output/bool: OK /string-visitor/output/bool: OK /string-visitor/output/number: /home/petmay01/linaro/qemu-from-laptop/qemu/qapi/string-output-visitor.c:92:16:OK runtime error: signed integer overflow: 9223372036854775807 /string-visitor/output/number: + 1 cannot be represented in type 'long' OK /string-visitor/output/string: OK [etc] and later TEST: tests/test-visitor-serialization... (pid=31729) [etc] /visitor/serialization/String/primitives/boolean_true2: OK /visitor/serialization/String/primitives/boolean_true3: OK /visitor/serialization/String/primitives/boolean_false1: OK /visitor/serialization/String/primitives/boolean_false2: /home/petmay01/linaro/qemu-from-laptop/qemu/qapi/string-output-visitor.c:83:16:OK /visitor/serialization/String/primitives/number_sanity1: runtime error: signed integer overflow: 9223372036854775807 + 1 cannot be represented in type OK 'long' /visitor/serialization/String/primitives/number_sanity2: /home/petmay01/linaro/qemu-from-laptop/qemu/qapi/string-input-visitor.c:58:34:OK runtime error: signed integer overflow: /visitor/serialization/String/primitives/number_min: 9223372036854775807 + 1 cannot be represented in type 'long long' OK /home/petmay01/linaro/qemu-from-laptop/qemu/qapi/string-input-visitor.c:216:13: runtime error: /visitor/serialization/String/primitives/number_max: signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'int64_t' (aka 'long') OK /visitor/serialization/String/primitives/integer_sanity1: OK /visitor/serialization/String/primitives/integer_sanity2: OK [etc] You can also see these without clang if you run under gdb and put in appropriate conditional breakpoints (eg string_output_append_range() with condition (e > 50000). Sample backtrace: (gdb) bt #0 string_output_append_range (sov=0x5555557adbc0, s=9223372036854775806, e=9223372036854775807) at /home/petmay01/linaro/qemu-from-laptop/qemu/qapi/string-output-visitor.c:89 #1 0x000055555558285c in print_type_int (v=0x5555557adbc0, obj=0x5555557adec0, name=0x0, errp=0x7fffffffdec8) at /home/petmay01/linaro/qemu-from-laptop/qemu/qapi/string-output-visitor.c:158 #2 0x00005555555800ab in visit_type_int (v=0x5555557adbc0, obj=0x5555557adec0, name=0x0, errp=0x7fffffffdec8) at /home/petmay01/linaro/qemu-from-laptop/qemu/qapi/qapi-visit-core.c:100 #3 0x000055555555e73f in visit_type_intList (m=0x5555557adbc0, obj=0x7fffffffdf28, name=0x0, errp=0x7fffffffdf30) at qapi-visit.c:57 #4 0x0000555555558263 in test_visitor_out_intList (data=0x5555557adb30, unused=0x7fffffffe350) at /home/petmay01/linaro/qemu-from-laptop/qemu/tests/test-string-output-visitor.c:93 #5 0x00007ffff7b3ea81 in test_case_run (tc=0x5555557ad500) at /build/buildd/glib2.0-2.40.2/./glib/gtestutils.c:2059 #6 g_test_run_suite_internal (suite=suite@entry=0x5555557ac860, path=path@entry=0x7ffff7b956de "") at /build/buildd/glib2.0-2.40.2/./glib/gtestutils.c:2120 #7 0x00007ffff7b3ec46 in g_test_run_suite_internal (suite=suite@entry=0x5555557ac840, path=path@entry=0x7ffff7b956de "") at /build/buildd/glib2.0-2.40.2/./glib/gtestutils.c:2131 #8 0x00007ffff7b3ec46 in g_test_run_suite_internal (suite=suite@entry=0x5555557ac820, path=path@entry=0x7ffff7b956de "") at /build/buildd/glib2.0-2.40.2/./glib/gtestutils.c:2131 #9 0x00007ffff7b3ef9b in g_test_run_suite (suite=0x5555557ac820) at /build/buildd/glib2.0-2.40.2/./glib/gtestutils.c:2184 #10 0x00007ffff7b3efd1 in g_test_run () at /build/buildd/glib2.0-2.40.2/./glib/gtestutils.c:1488 #11 0x0000555555558fee in main (argc=1, argv=0x7fffffffe468) at /home/petmay01/linaro/qemu-from-laptop/qemu/tests/test-string-output-visitor.c:286 and you can see that 'e' is the max 64 bit signed integer and we're about to increment it... Paolo, the file says you wrote this code? thanks -- PMM