public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "manuel.lauss at googlemail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/103961] New: gcc-12 apparently miscompiles libcap's cap_to_text() function
Date: Mon, 10 Jan 2022 12:33:27 +0000	[thread overview]
Message-ID: <bug-103961-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 103961
           Summary: gcc-12 apparently miscompiles libcap's cap_to_text()
                    function
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: manuel.lauss at googlemail dot com
  Target Milestone: ---

Created attachment 52152
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52152&action=edit
preprocessed source file

gcc-12 apparently miscompiles the libcap-2.62 function "cap_to_text()".
I've seen it manifest with "ls" segfaulting in certain directories:

$ ls
*** buffer overflow detected ***: terminated
Aborted (core dumped)


#0  __pthread_kill_implementation (threadid=<optimized out>,
signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
44            return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO
(ret) : 0;
(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>,
signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007f34f856932f in __pthread_kill_internal (signo=6, threadid=<optimized
out>) at pthread_kill.c:78
#2  0x00007f34f8518e42 in __GI_raise (sig=sig@entry=6) at
../sysdeps/posix/raise.c:26
#3  0x00007f34f8503457 in __GI_abort () at abort.c:79
#4  0x00007f34f855d5a8 in __libc_message (action=action@entry=do_abort,
fmt=fmt@entry=0x7f34f8690291 "*** %s ***: terminated\n") at
../sysdeps/posix/libc_fatal.c:155
#5  0x00007f34f85fb042 in __GI___fortify_fail (msg=msg@entry=0x7f34f8690237
"buffer overflow detected") at fortify_fail.c:26
#6  0x00007f34f85f9b60 in __GI___chk_fail () at chk_fail.c:28
#7  0x00007f34f85f96d5 in ___sprintf_chk (s=s@entry=0x7fff9f08c6c2 ",",
flag=flag@entry=1, slen=slen@entry=0, format=format@entry=0x7f34f86dc085
"%c%s%s%s")
    at sprintf_chk.c:37
#8  0x00007f34f86da882 in sprintf (__fmt=0x7f34f86dc085 "%c%s%s%s",
__s=<optimized out>) at /usr/include/bits/stdio2.h:38
#9  cap_to_text (caps=0x5643cf9b1a38, length_p=0x0) at cap_text.c:431
#10 0x00005643cf983285 in ?? ()

If I replace the cap_text.o file from the gcc-12 build with one from a gcc-11.3
build, the error disappears.  It also disappears when ls is run under strace.
-fno-tree-vectorize does NOT help.

Find attached the preprocessed cap_text.i file from libcap-2.62, as well as
.S files of gcc-11.3 and 12.0

gcc version 12.0.0 20220110 (experimental) (Gentoo 12.0.0_pre9999 p2, commit
92e114d66e93d60dcef97c66cddbae38b657d768)

             reply	other threads:[~2022-01-10 12:33 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-10 12:33 manuel.lauss at googlemail dot com [this message]
2022-01-10 12:34 ` [Bug c/103961] " manuel.lauss at googlemail dot com
2022-01-10 12:34 ` manuel.lauss at googlemail dot com
2022-01-10 12:50 ` [Bug middle-end/103961] [12 Regression] " pinskia at gcc dot gnu.org
2022-01-10 13:06 ` pinskia at gcc dot gnu.org
2022-01-10 13:11 ` pinskia at gcc dot gnu.org
2022-01-10 13:12 ` pinskia at gcc dot gnu.org
2022-01-10 13:14 ` pinskia at gcc dot gnu.org
2022-01-10 13:19 ` [Bug tree-optimization/103961] " pinskia at gcc dot gnu.org
2022-01-10 13:35 ` rguenth at gcc dot gnu.org
2022-01-11  2:02 ` pinskia at gcc dot gnu.org
2022-01-11  2:12 ` pinskia at gcc dot gnu.org
2022-01-11  2:13 ` pinskia at gcc dot gnu.org
2022-01-11  9:10 ` [Bug tree-optimization/103961] [12 Regression] gcc-12 apparently miscompiles libcap's cap_to_text() function since r12-6030-g422f9eb7011b76c1 marxin at gcc dot gnu.org
2022-01-11  9:18 ` marxin at gcc dot gnu.org
2022-01-11  9:27 ` jakub at gcc dot gnu.org
2022-01-11  9:35 ` siddhesh at gcc dot gnu.org
2022-01-11 13:00 ` rguenth at gcc dot gnu.org
2022-01-11 14:48 ` cvs-commit at gcc dot gnu.org
2022-01-11 14:52 ` siddhesh at gcc dot gnu.org
2022-01-11 16:11 ` manuel.lauss at googlemail dot com
2022-01-11 16:20 ` jakub 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-103961-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).