qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Unit Test Aborts when building with -ftrapv compiler option
@ 2024-02-08 19:23 Richard Schmitt
  2024-02-09  7:02 ` Thomas Huth
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Schmitt @ 2024-02-08 19:23 UTC (permalink / raw)
  To: qemu-devel@nongnu.org


[-- Attachment #1.1: Type: text/plain, Size: 1159 bytes --]

In an attempt to build qemu with hardened gcc compiler options, we specified the -ftrapv switch rather than the -fwrapv switch. The switches define the behavior of integer overflows. -ftrapv causes an abort on integer overflow, -fwrapv causes overflows to simply wrap without any error indication. Wrapping overflows can result in unexpected behavior and therefore, hardenened builds typically recommend trapping overflows. 

The abort occurs when running the “test-string-input-verifier” test and begins at line 129 of the source:

v = visitor_input_test_init(data, 
“-9223372036854775808, 9223372036854775807”); 
check_ilist(v, expect3, ARRAY_SIZE(expect3); 

Where expect3 is declared as: 

int64_t expect3[] = { INT64_MIN, INT64_MAX }; 

The actual abort occurs in “string-input-visitor.c” line 209:

*obj = siv->rangeNext.i64++; 

The test, as coded, will generate an overflow. Using the -fwrapv compiler option hides the overflow. 

My question, is it the intent of the qemu community to rely on the overflow wrap behavior or should this be considered an issue and added as such in gitlab’s issue list? 

Rich 



[-- Attachment #1.2: Type: text/html, Size: 4803 bytes --]

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 8404 bytes --]

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

end of thread, other threads:[~2024-02-09  9:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-08 19:23 Unit Test Aborts when building with -ftrapv compiler option Richard Schmitt
2024-02-09  7:02 ` Thomas Huth
2024-02-09  9:41   ` Daniel P. Berrangé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).