public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/112783] New: core dump on libxo when function is inlined
@ 2023-11-30 13:32 yancheng.li at foxmail dot com
  2023-12-01  5:06 ` [Bug ipa/112783] " sjames at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: yancheng.li at foxmail dot com @ 2023-11-30 13:32 UTC (permalink / raw)
  To: gcc-bugs

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
```

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-01-05 14:38 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-30 13:32 [Bug ipa/112783] New: core dump on libxo when function is inlined yancheng.li at foxmail dot com
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

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).