From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9AE953858D37; Thu, 30 Nov 2023 13:32:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9AE953858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701351173; bh=ifByRpKl5huqB0TgvaQlHCjwKGTdHZwfpfzYtzgp1dY=; h=From:To:Subject:Date:From; b=olNMe73WXy1MdUiaJVuBi+NF8cYn1e7kkou+TVKiUtOBr6jojFGLmHwFiwMqQbIpn 2XAlMhwOp1aTffBPrVCoNPxP1ikC4PoiCTG34UvJsTdJOUk3sZS8iRKTP+KUd2dMKF 6pIJv4fbl+jcyNKMJJOGdTF3CYM/C6kR/AMbpLMw= From: "yancheng.li at foxmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: yancheng.li at foxmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112783 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=3D$LD_LIBRARY_PATH:/usr/local/lib/ [root@localhost build]# cat test.c #include 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=3D0, name=3D0x0, xop=3D0xffff= f7ddbe00) at ../../libxo/libxo.c:567 567 if (name =3D=3D NULL || isalpha(name[0]) || name[0] =3D=3D '_') (gdb) bt #0 0x0000fffff7f9d4b8 in xo_xml_leader_len (nlen=3D0, name=3D0x0, xop=3D0xfffff7ddbe00) at ../../libxo/libxo.c:567 #1 xo_format_value (xop=3Dxop@entry=3D0xfffff7ddbe00, name=3Dname@entry=3D= 0x0, nlen=3Dnlen@entry=3D0, value=3Dvalue@entry=3D0x0, vlen=3Dvlen@entry=3D0, fm= t=3D0x4006e4 "%-*.*s}{etk:name}{eq:flags/0x%x}", flen=3D6, encoding=3D0x0, elen=3D0, flags=3Dflags@entry=3D64) at ../../libxo/libxo.c:4362 #2 0x0000fffff7f9f434 in xo_do_emit_fields (xop=3Dxop@entry=3D0xfffff7ddbe= 00, fields=3Dfields@entry=3D0xffffffffe940, max_fields=3Dmax_fields@entry=3D9, = fmt=3D0x4006e0 "{d:/%-*.*s}{etk:name}{eq:flags/0x%x}") at ../../libxo/libxo.c:6372 #3 0x0000fffff7f9fa60 in xo_do_emit (xop=3Dxop@entry=3D0xfffff7ddbe00, flags=3D, flags@entry=3D0, fmt=3Dfmt@entry=3D0x4006e0 "{d:/%-*.*s}{etk:name}{eq:flags/0x%x}") at ../../libxo/libxo.c:6551 #4 0x0000fffff7f9fd04 in xo_emit (fmt=3D0x4006e0 "{d:/%-*.*s}{etk:name}{eq:flags/0x%x}") at ../../libxo/libxo.c:6622 #5 0x00000000004006b4 in main (argc=3D1, argv=3D0xffffffffef98) at test.c:5 ```=