All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] clang -fsanitize=undefined warnings in the string visitors
@ 2014-12-23 23:17 Peter Maydell
  2015-02-05 17:03 ` Peter Maydell
  0 siblings, 1 reply; 13+ messages in thread
From: Peter Maydell @ 2014-12-23 23:17 UTC (permalink / raw)
  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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-01-14 12:53 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-23 23:17 [Qemu-devel] clang -fsanitize=undefined warnings in the string visitors Peter Maydell
2015-02-05 17:03 ` Peter Maydell
2015-05-11  8:53   ` Peter Maydell
2015-05-11  9:07     ` Paolo Bonzini
2015-05-29 10:56       ` Peter Maydell
2015-05-29 11:12         ` Paolo Bonzini
2015-10-01 10:47           ` Peter Maydell
2015-10-01 13:38             ` Paolo Bonzini
2015-11-05 20:05               ` John Snow
2016-01-14 11:15                 ` Peter Maydell
2016-01-14 12:44                   ` Paolo Bonzini
2016-01-14 12:52                     ` Peter Maydell
2015-10-01 14:58             ` Eric Blake

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.