From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 25715385C32B; Tue, 2 Aug 2022 07:47:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 25715385C32B From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/106503] "const char []" in local scope never initialized Date: Tue, 02 Aug 2022 07:47:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 11.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Aug 2022 07:47:55 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106503 --- Comment #3 from Andrew Pinski --- (In reply to Andrew Pinski from comment #2) > -fsanitize=3Daddress sometimes can detect this kind of problems at runtim= e. Program returned: 1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D1=3D=3DERROR: AddressSanitizer: stack-use-after-scope on address 0x7f= 9235600030 at pc 0x7f9237ebcc9b bp 0x7ffc8cccff60 sp 0x7ffc8cccf720 READ of size 3 at 0x7f9235600030 thread T0 #0 0x7f9237ebcc9a=20 (/opt/compiler-explorer/gcc-snapshot/lib64/libasan.so.8+0x4ac9a) (BuildId: f4e296dda2fcdab4980780e7f32c752a3e412556) #1 0x7f9237ebcf37 in writev (/opt/compiler-explorer/gcc-snapshot/lib64/libasan.so.8+0x4af37) (BuildId: f4e296dda2fcdab4980780e7f32c752a3e412556) #2 0x401673 in main (/app/output.s+0x401673) (BuildId: af556f86dec87e7467f73a633f83c822f3afe85a) #3 0x7f923790b0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b2) (BuildId: 9fdb74e7b217d06c93172a8243f8547f947ee6d1) #4 0x4010ed in _start (/app/output.s+0x4010ed) (BuildId: af556f86dec87e7467f73a633f83c822f3afe85a) Address 0x7f9235600030 is located in stack of thread T0 at offset 48 in fra= me #0 0x4011b5 in main (/app/output.s+0x4011b5) (BuildId: af556f86dec87e7467f73a633f83c822f3afe85a) This frame has 2 object(s): [48, 52) 'junk' (line 22) <=3D=3D Memory access at offset 48 is inside = this variable [64, 384) 'wdata' (line 15) 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-use-after-scope (/opt/compiler-explorer/gcc-snapshot/lib64/libasan.so.8+0x4ac9a) (BuildId: f4e296dda2fcdab4980780e7f32c752a3e412556)=20 Shadow bytes around the buggy address: 0x0ff2c6ab7fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0ff2c6ab7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0ff2c6ab7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0ff2c6ab7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0ff2c6ab7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =3D>0x0ff2c6ab8000: f1 f1 f1 f1 f1 f1[f8]f2 00 00 00 00 00 00 00 00 0x0ff2c6ab8010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0ff2c6ab8020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0ff2c6ab8030: f3 f3 f3 f3 f3 f3 f3 f3 00 00 00 00 00 00 00 00 0x0ff2c6ab8040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0ff2c6ab8050: 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=20 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 =3D=3D1=3D=3DABORTING fooabcbaz=