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

            Bug ID: 124413
           Summary: aarch64; hwasan test failures with -fstack-protector
           Product: gcc
           Version: 15.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: testsuite
          Assignee: unassigned at gcc dot gnu.org
          Reporter: siddhesh at gcc dot gnu.org
  Target Milestone: ---

The following hwasan tests fail on aarch64 when gcc is built with
-fstack-protector:

```
c-c++-common/hwasan/bitfield-2.c
c-c++-common/hwasan/hwasan-thread-basic-failure.c
c-c++-common/hwasan/unprotected-allocas-1.c
```

Example failure:

```
spawn [open ...]^M
==10487==ERROR: HWAddressSanitizer: tag-mismatch on address 0xffffefcf6120 at
pc 0xffffaaeddc10
READ of size 2 at 0xffffefcf6120 tags: 02/01(00) (ptr/mem) in thread T0
    #0 0xffffaaeddc10 in __hwasan_load2 (/lib64/libhwasan.so.0+0x1dc10)
(BuildId: e59490e6a224cc2e541e17c65d779cd8a94229b4)
    #1 0x4008a0 in f
/root/rpmbuild/BUILD/gcc-14.3.1-20251022/gcc/testsuite/c-c++-common/hwasan/bitfield-2.c:17
 
    #2 0x400940 in main
/root/rpmbuild/BUILD/gcc-14.3.1-20251022/gcc/testsuite/c-c++-common/hwasan/bitfield-2.c:24
    #3 0xffffaac76118 in __libc_start_call_main (/lib64/libc.so.6+0x26118)
(BuildId: e99610b277e5fba1a79aa464477d3810d3bdf545)
    #4 0xffffaac761f8 in __libc_start_main@GLIBC_2.17
(/lib64/libc.so.6+0x261f8) (BuildId: e99610b277e5fba1a79aa464477d3810d3bdf545)
    #5 0x4007ac in _start (/root/bitfield-2.exe+0x4007ac) (BuildId:
e035cfdafc2e8197bb149c386b2b51ba5fa7f08f)


Cause: stack tag-mismatch
Address 0xffffefcf6120 is located in stack of thread T0
Thread: T0 0xeffe00002000 stack: [0xffffef4f8000,0xffffefcf8000) sz: 8388608
tls: [0xffffab511020,0xffffab511ee0)
Previously allocated frames:
Memory tags around the buggy address (one tag corresponds to 16 bytes):
  0xffffefcf5900: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00 
00
  0xffffefcf5a00: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00 
00
  0xffffefcf5b00: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00 
00
  0xffffefcf5c00: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00 
00
  0xffffefcf5d00: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00 
00
  0xffffefcf5e00: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00 
00
  0xffffefcf5f00: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00 
00
  0xffffefcf6000: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00 
00
=>0xffffefcf6100: 00  02 [01] 00  00  00  00  00  00  00  00  00  00  00  00 
00
  0xffffefcf6200: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00 
00
  0xffffefcf6300: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00 
00
  0xffffefcf6400: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00 
00
  0xffffefcf6500: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00 
00
  0xffffefcf6600: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00 
00
  0xffffefcf6700: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00 
00
  0xffffefcf6800: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00 
00
  0xffffefcf6900: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00 
00
Tags for short granules around the buggy address (one tag corresponds to 16
bytes):
  0xffffefcf6000: ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  .. 
..
=>0xffffefcf6100: ..  00 [00] ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  .. 
..
  0xffffefcf6200: ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  .. 
..
See
https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html#short-granules
for a description of short granule tags
SUMMARY: HWAddressSanitizer: tag-mismatch (/lib64/libhwasan.so.0+0x1dc10)
(BuildId: e59490e6a224cc2e541e17c65d779cd8a94229b4) in __hwasan_load2
PASS: c-c++-common/hwasan/bitfield-2.c   -O0  execution test
FAIL: c-c++-common/hwasan/bitfield-2.c   -O0  output pattern test
```

It looks like the output regex expectations are a bit out of whack when built
with stack-protector, e.g. we get tags as 02/01 instead of the expected 02/00.

Reply via email to