public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/96318] New: FAIL: c-c++-common/asan/strncpy-overflow-1.c  * output pattern test with C on Darwin
@ 2020-07-25  9:30 dominiq at lps dot ens.fr
  2020-07-27  6:57 ` [Bug sanitizer/96318] " marxin at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: dominiq at lps dot ens.fr @ 2020-07-25  9:30 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96318
           Summary: FAIL: c-c++-common/asan/strncpy-overflow-1.c  * output
                    pattern test with C on Darwin
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dominiq at lps dot ens.fr
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    iains 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: ---

With G++ the output is

=================================================================
==80414==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x6020000000f9 at pc 0x0001101655f0 bp 0x7ffedfdf30c0 sp 0x7ffedfdf2870
WRITE of size 10 at 0x6020000000f9 thread T0
    #0 0x1101655ef in wrap_strncpy
/opt/gcc/build_w/x86_64-apple-darwin19.5.0/libsanitizer/asan/../../../../work/libsanitizer/asan/asan_interceptors.cpp:483:5
    #1 0x10fe09d8d in main
/opt/gcc/work/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c:11:10
    #2 0x7fff6e3decc8 in start (/usr/lib/system/libdyld.dylib:x86_64+0x1acc8)

0x6020000000f9 is located 0 bytes to the right of 9-byte region
[0x6020000000f0,0x6020000000f9)
allocated by thread T0 here:
    #0 0x110196d37 in wrap_malloc
/opt/gcc/build_w/x86_64-apple-darwin19.5.0/libsanitizer/asan/../../../../work/libsanitizer/sanitizer_common/sanitizer_malloc_mac.inc:140:3
    #1 0x10fe09d71 in main
/opt/gcc/work/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c:10:37
    #2 0x7fff6e3decc8 in start (/usr/lib/system/libdyld.dylib:x86_64+0x1acc8)
...

which matches

/* { dg-output "WRITE of size \[0-9\]* at 0x\[0-9a-f\]+ thread
T0\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "    #0 0x\[0-9a-f\]+ +(in
_*(interceptor_|wrap_|)strncpy|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "    #1 0x\[0-9a-f\]+ +(in _*main
(\[^\n\r]*strncpy-overflow-1.c:11|\[^\n\r]*:0|\[^\n\r]*\\+0x\[0-9a-z\]*)|\[(\]).*(\n|\r\n|\r)"
} */
/* { dg-output "\[^\n\r]*0x\[0-9a-f\]+ is located 0 bytes to the right of
9-byte region\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" }
*/
/* { dg-output "    #0 0x\[0-9a-f\]+ +(in
_*(interceptor_|wrap_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "    #1 0x\[0-9a-f\]+ +(in _*main
(\[^\n\r]*strncpy-overflow-1.c:10|\[^\n\r]*:0|\[^\n\r]*\\+0x\[0-9a-z\]*)|\[(\])\[^\n\r]*(\n|\r\n|\r)"
} */

With GCC the output is

=================================================================
==82801==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x6020000000f9 at pc 0x00010df36d79 bp 0x7ffee1cf0670 sp 0x7ffee1cefe20
WRITE of size 5 at 0x6020000000f9 thread T0
    #0 0x10df36d78 in wrap___bzero.part.0
/opt/gcc/build_w/x86_64-apple-darwin19.5.0/libsanitizer/asan/../../../../work/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:5584:3
    #1 0x7fff6e43fc42 in stpncpy
(/usr/lib/system/libsystem_c.dylib:x86_64+0x11c42)
    #2 0x7fff6e4ab34a in __strncpy_chk
(/usr/lib/system/libsystem_c.dylib:x86_64+0x7d34a)
    #3 0x10df0cd8d in main
/opt/gcc/work/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c:11:3
    #4 0x7fff6e3decc8 in start (/usr/lib/system/libdyld.dylib:x86_64+0x1acc8)

0x6020000000f9 is located 0 bytes to the right of 9-byte region
[0x6020000000f0,0x6020000000f9)
allocated by thread T0 here:
    #0 0x10df60d37 in wrap_malloc
/opt/gcc/build_w/x86_64-apple-darwin19.5.0/libsanitizer/asan/../../../../work/libsanitizer/sanitizer_common/sanitizer_malloc_mac.inc:140:3
    #1 0x10df0cd6a in main
/opt/gcc/work/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c:10:31
    #2 0x7fff6e3decc8 in start (/usr/lib/system/libdyld.dylib:x86_64+0x1acc8)
...

with two extra lines not expected in the output regexpr.

Questions:

(1) Why gcc on Darwin outputs these extra lines?
(2) Is there some magic incantation to ovoid it?
(3) What to do with the test on Darwin?

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

end of thread, other threads:[~2022-05-27  8:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-25  9:30 [Bug sanitizer/96318] New: FAIL: c-c++-common/asan/strncpy-overflow-1.c * output pattern test with C on Darwin dominiq at lps dot ens.fr
2020-07-27  6:57 ` [Bug sanitizer/96318] " marxin at gcc dot gnu.org
2021-03-13 11:55 ` dominiq at lps dot ens.fr
2021-03-24 14:16 ` iains at gcc dot gnu.org
2021-03-24 22:07 ` cvs-commit at gcc dot gnu.org
2021-06-01  8:18 ` rguenth at gcc dot gnu.org
2022-05-27  8:55 ` rguenth 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).