diff options
author | Tom de Vries <tdevries@suse.de> | 2022-05-23 14:50:02 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2022-05-23 14:50:02 +0200 |
commit | 735dfe028c93f20026339f3eeeadacac82fe7963 (patch) | |
tree | 052155f9eb95bd561fbdfdc67f4e45f63d7bd26e /gdbsupport/common-gdbthread.h | |
parent | 5a3cf18c2ed9593f194ea22f50ea5651532f6cfc (diff) | |
download | gdb-735dfe028c93f20026339f3eeeadacac82fe7963.zip gdb-735dfe028c93f20026339f3eeeadacac82fe7963.tar.gz gdb-735dfe028c93f20026339f3eeeadacac82fe7963.tar.bz2 |
[gdbsupport] Fix UB in print-utils.cc:int_string
When building gdb with -fsanitize=undefined, I run into:
...
(gdb) PASS: gdb.ada/access_to_packed_array.exp: set logging enabled on
maint print symbols^M
print-utils.cc:281:29:runtime error: negation of -9223372036854775808 cannot \
be represented in type 'long int'; cast to an unsigned type to negate this \
value to itself
(gdb) FAIL: gdb.ada/access_to_packed_array.exp: maint print symbols
...
By running in a debug session, we find that this happens during printing of:
...
typedef system.storage_elements.storage_offset: \
range -9223372036854775808 .. 9223372036854775807;
...
Possibly, an ada test-case could be created that exercises this in isolation.
The problem is here in int_string, where we negate a val with type LONGEST:
...
return decimal2str ("-", -val, width);
...
Fix this by, as recommend, using "-(ULONGEST)val" instead.
Tested on x86_64-linux.
Diffstat (limited to 'gdbsupport/common-gdbthread.h')
0 files changed, 0 insertions, 0 deletions