public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "yancheng.li at foxmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/112783] New: core dump on libxo when function is inlined
Date: Thu, 30 Nov 2023 13:32:52 +0000	[thread overview]
Message-ID: <bug-112783-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112783

            Bug ID: 112783
           Summary: core dump on libxo when function is inlined
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yancheng.li at foxmail dot com
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Hi all, i meet a segment fault when using libxo compiled with gcc 10 or gcc
trunk.

I found we can skip this problem when add attribute((noinline)) on the wrong
function  "xo_xml_leader_len".

we can use these following commands to reproduce the problem:
```
yum install libtool git make
cp /usr/include/linux/sysctl.h /usr/include/sys/sysctl.h

git clone http://github.com/Juniper/libxo.git

sh bin/setup.sh
cd build
../configure
make
make install
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/


[root@localhost build]# cat test.c
#include <libxo/xo.h>

int main(int argc, char *argv[])
{
   xo_emit("{d:/%-*.*s}{etk:name}{eq:flags/0x%x}", 0, 0, NULL, NULL, 0);
}

gcc test.c -g -L /usr/local/lib/ -lxo -I /usr/local/include/libxo -o test
./test
Segmentation fault (core dumped)

Program received signal SIGSEGV, Segmentation fault.
0x0000fffff7f9d4b8 in xo_xml_leader_len (nlen=0, name=0x0, xop=0xfffff7ddbe00)
at ../../libxo/libxo.c:567
567         if (name == NULL || isalpha(name[0]) || name[0] == '_')
(gdb) bt
#0  0x0000fffff7f9d4b8 in xo_xml_leader_len (nlen=0, name=0x0,
xop=0xfffff7ddbe00) at ../../libxo/libxo.c:567
#1  xo_format_value (xop=xop@entry=0xfffff7ddbe00, name=name@entry=0x0,
nlen=nlen@entry=0, value=value@entry=0x0, vlen=vlen@entry=0, fmt=0x4006e4
"%-*.*s}{etk:name}{eq:flags/0x%x}", flen=6, encoding=0x0, elen=0,
    flags=flags@entry=64) at ../../libxo/libxo.c:4362
#2  0x0000fffff7f9f434 in xo_do_emit_fields (xop=xop@entry=0xfffff7ddbe00,
fields=fields@entry=0xffffffffe940, max_fields=max_fields@entry=9, fmt=0x4006e0
"{d:/%-*.*s}{etk:name}{eq:flags/0x%x}")
    at ../../libxo/libxo.c:6372
#3  0x0000fffff7f9fa60 in xo_do_emit (xop=xop@entry=0xfffff7ddbe00,
flags=<optimized out>, flags@entry=0, fmt=fmt@entry=0x4006e0
"{d:/%-*.*s}{etk:name}{eq:flags/0x%x}") at ../../libxo/libxo.c:6551
#4  0x0000fffff7f9fd04 in xo_emit (fmt=0x4006e0
"{d:/%-*.*s}{etk:name}{eq:flags/0x%x}") at ../../libxo/libxo.c:6622
#5  0x00000000004006b4 in main (argc=1, argv=0xffffffffef98) at test.c:5
```

             reply	other threads:[~2023-11-30 13:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-30 13:32 yancheng.li at foxmail dot com [this message]
2023-12-01  5:06 ` [Bug ipa/112783] " sjames at gcc dot gnu.org
2023-12-01 23:33 ` pinskia at gcc dot gnu.org
2023-12-01 23:53 ` pinskia at gcc dot gnu.org
2023-12-12  3:40 ` yancheng.li at foxmail dot com
2023-12-12  3:45 ` pinskia at gcc dot gnu.org
2023-12-12  3:45 ` pinskia at gcc dot gnu.org
2023-12-15 21:09 ` cvs-commit at gcc dot gnu.org
2023-12-15 21:15 ` jvdelisle at gcc dot gnu.org
2024-01-05  3:09 ` jiangchuanganghw at outlook dot com
2024-01-05 14:38 ` xry111 at gcc dot gnu.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-112783-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: link
Be 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).