public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "marko.makela at mariadb dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug sanitizer/98669] New: SIGSEGV on pc=0 in crypt() with -fsanitize=address
Date: Thu, 14 Jan 2021 07:40:42 +0000	[thread overview]
Message-ID: <bug-98669-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 98669
           Summary: SIGSEGV on pc=0 in crypt() with -fsanitize=address
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marko.makela at mariadb dot com
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at gcc dot gnu.org
  Target Milestone: ---

The following test program would crash when compiled with AddressSanitizer
instrumentation in GCC 10.2.1 for AMD64 on Debian GNU/Linux Sid (unstable):

cat > crypt.c << EOF
#include <crypt.h>
#include <stdio.h>

int main (int argc, char **argv)
{
  puts(crypt(*argv, "salt"));
}
EOF
gcc -fsanitize=address crypt.c -lcrypt
./a.out


AddressSanitizer:DEADLYSIGNAL
=================================================================
==664877==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc
0x000000000000 bp 0x7fffb2b2b970 sp 0x7fffb2b2b958 T0)
==664877==Hint: pc points to the zero page.
==664877==The signal is caused by a READ memory access.
==664877==Hint: address points to the zero page.
    #0 0x0  (<unknown module>)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (<unknown module>) 
==664877==ABORTING


If I compile the same without -fsanitize=address, or with clang-10 or clang-11,
the program will complete normally, outputting a line of text.

I traced the crash to the second (!) invocation of the function
__interceptor_crypt():

gdb a.out
break __interceptor_crypt
continue
display/i $pc
continue
nexti
nexti
...

The trace would end with the following:

1: x/i $pc
=> 0x7ffff762ba4d <__interceptor_crypt(char*, char*)+125>:      
    jmp    *0xdf55d(%rip)        # 0x7ffff770afb0
<_ZN14__interception10real_cryptE>
(gdb) 
0x0000000000000000 in ?? ()

             reply	other threads:[~2021-01-14  7:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-14  7:40 marko.makela at mariadb dot com [this message]
2021-01-14  8:15 ` [Bug sanitizer/98669] " marxin at gcc dot gnu.org
2021-01-14  9:32 ` marko.makela at mariadb dot com
2021-01-14 10:25 ` doko at debian dot org
2021-01-14 10:36 ` doko at debian dot org
2021-01-14 10:43 ` marxin at gcc dot gnu.org
2021-01-14 10:51 ` marxin at gcc dot gnu.org
2021-01-14 10:52 ` doko at debian dot org
2021-01-14 10:56 ` marxin at gcc dot gnu.org
2021-01-14 11:39 ` doko at debian dot org
2021-01-14 11:45 ` jakub at gcc dot gnu.org
2021-01-14 13:11 ` doko at debian dot org
2021-01-14 13:35 ` marxin at gcc dot gnu.org
2021-01-14 16:25 ` marko.makela at mariadb dot com
2022-09-06  7:05 ` asn at samba dot 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-98669-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).