public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "bruno at clisp dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/112708] New: "gcc -fsanitize=address" produces wrong debug info for variables in function prologue Date: Sat, 25 Nov 2023 04:35:49 +0000 [thread overview] Message-ID: <bug-112708-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112708 Bug ID: 112708 Summary: "gcc -fsanitize=address" produces wrong debug info for variables in function prologue Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: bruno at clisp dot org CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org, jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at gcc dot gnu.org Target Milestone: --- As "gcc -fsanitize=address" finds several categories of memory related bugs, I'm trying to use CC="gcc -fsanitize=address" everywhere. Unfortunately, in the following case, a variable's value during a function prologue is wrong when displayed by gdb. The value is displayed correctly when I don't use the option -fsanitize=address. Which means that the culprit is gcc. How to reproduce: 1. $ wget https://ftp.gnu.org/gnu/gettext/gettext-0.22.tar.xz 2. $ tar xf gettext-0.22.tar.xz 3. $ cd gettext-0.22 4. $ GCC13DIR=/some/directory/with/gcc-13.2.0 $ PATH=$GCC13DIR/bin:$PATH Verify it: $ gcc --version 5. $ CC="gcc -fsanitize=address" CXX="g++ -fsanitize=address -Wl,-rpath,$GCC13DIR/lib64" CFLAGS=-ggdb ./configure --disable-shared 6. $ make 7. $ cd gettext-tools/src 8. $ cat > foo.vala <<\EOF primary_text.set_markup( "<span size=\"large\" weight=\"bold\">%s</span>".printf(_("Welcome to Shotwell!"))); EOF 9. $ gdb xgettext GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1 Copyright (C) 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <https://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from xgettext... (gdb) break xg-message.c:383 Breakpoint 1 at 0x41cad1: file xg-message.c, line 383. (gdb) run -o - foo.vala Starting program: /tmp/gettext-0.22/gettext-tools/src/xgettext -o - foo.vala [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Breakpoint 1, remember_a_message (mlp=0x60e000000040, msgctxt=0x0, msgid=0x603000000a30 "Welcome to Shotwell!", is_utf8=true, pluralp=false, context=..., pos=0x6100000004c0, extracted_comment=0x0, comment=0x0, comment_is_utf8=false) at xg-message.c:383 383 set_format_flags_from_context (is_format, context, mp->msgid, pos, "msgid"); (gdb) print context $1 = {is_format1 = 3, pass_format1 = 0, is_format2 = 0, pass_format2 = 0, is_format3 = 0, pass_format3 = 0, is_format4 = 0, pass_format4 = 0} (gdb) step set_format_flags_from_context (is_format=0x7fffffffc620, context=..., string=0x603000000a30 "Welcome to Shotwell!", pos=0x6100000004c0, pretty_msgstr=0x6f0d40 "msgid") at xg-message.c:50 50 flag_context_ty context, const char *string, (gdb) print context $2 = {is_format1 = 0, pass_format1 = 0, is_format2 = 2, pass_format2 = 0, is_format3 = 5, pass_format3 = 0, is_format4 = 7, pass_format4 = 0} (gdb) next 55 if (context.is_format1 != undecided (gdb) print context $3 = {is_format1 = 3, pass_format1 = 0, is_format2 = 0, pass_format2 = 0, is_format3 = 0, pass_format3 = 0, is_format4 = 0, pass_format4 = 0} The variable 'context' is passed from xg-message.c:383 to set_format_flags_from_context. The value printed as $1 and $3 is correct. The value printed as $2 is nonsense.
next reply other threads:[~2023-11-25 4:35 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-11-25 4:35 bruno at clisp dot org [this message] 2023-11-25 4:54 ` [Bug sanitizer/112708] " pinskia at gcc dot gnu.org 2023-11-25 4:54 ` pinskia at gcc dot gnu.org 2023-11-25 4:56 ` pinskia at gcc dot gnu.org 2023-11-25 5:50 ` bruno at clisp dot org 2023-11-25 6:22 ` bruno at clisp dot org 2023-11-26 2:08 ` bruno at clisp dot org 2023-11-27 8:04 ` rguenth at gcc dot gnu.org 2023-11-27 10:07 ` bruno at clisp dot org 2023-11-27 10:29 ` jakub at gcc dot gnu.org 2023-11-28 1:03 ` bruno at clisp dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-112708-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).