[Bug libstdc++/103955] std::to_chars(char*, char*, double, std::chars_format, int precision) crashes for the two maximal int precision values
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Jan 9 22:27:53 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103955
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2022-01-09
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
With -fsanitize=address I get:
=================================================================
==1==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffd6d9523d7
at pc 0x7f37917b829e bp 0x7ffd6d9522c0 sp 0x7ffd6d951a70
WRITE of size 2147483594 at 0x7ffd6d9523d7 thread T0
#0 0x7f37917b829d in __interceptor_memset
(/opt/compiler-explorer/gcc-11.2.0/lib64/libasan.so.6+0x3c29d)
#1 0x7f37916cafa6
(/opt/compiler-explorer/gcc-11.2.0/lib64/libstdc++.so.6+0x162fa6)
#2 0x7f37916cb48c in std::to_chars(char*, char*, double, std::chars_format,
int) (/opt/compiler-explorer/gcc-11.2.0/lib64/libstdc++.so.6+0x16348c)
#3 0x4010fa in main /app/example.cpp:9
#4 0x7f37908c20b2 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
#5 0x4011ed in _start (/app/output.s+0x4011ed)
Address 0x7ffd6d9523d7 is located in stack of thread T0 at offset 103 in frame
#0 0x40107f in main /app/example.cpp:5
This frame has 1 object(s):
[48, 84) 'result' (line 6) <== Memory access at offset 103 overflows this
variable
HINT: this may be a false positive if your program uses some custom stack
unwind mechanism, swapcontext or vfork
(longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow
(/opt/compiler-explorer/gcc-11.2.0/lib64/libasan.so.6+0x3c29d) in
__interceptor_memset
Shadow bytes around the buggy address:
0x10002db22420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10002db22430: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10002db22440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10002db22450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10002db22460: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1
=>0x10002db22470: f1 f1 f1 f1 00 00 00 00 04 f3[f3]f3 f3 f3 00 00
0x10002db22480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10002db22490: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10002db224a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10002db224b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10002db224c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Shadow gap: cc
==1==ABORTING
More information about the Gcc-bugs
mailing list