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