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

            Bug ID: 99385
           Summary: [11 regression]
                    gcc.dg/tree-prof/indir-call-prof-malloc.c etc. FAIL
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ro at gcc dot gnu.org
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---
            Target: *-*-solaris2.11

Between 20210302 (f8e4d7a6597fa81ff927156a5f5d10b7fdaa0bc0) and 20210303
(39d7eb8a73d5f8c09db20926a98181181d9dd2c2), two tests began to FAIL on Solaris
(sparc and x86, 32 and 64-bit):

+UNRESOLVED: gcc.dg/tree-prof/indir-call-prof-malloc.c compilation, 
-fprofile-use -D_PROFILE_USE
+FAIL: gcc.dg/tree-prof/indir-call-prof-malloc.c execution,   
-fprofile-generate -D_PROFILE_GENERATE
+UNRESOLVED: gcc.dg/tree-prof/indir-call-prof-malloc.c execution,   
-fprofile-use -D_PROFILE_USE
+UNRESOLVED: gcc.dg/tree-prof/pr97461.c compilation,  -fprofile-use
-D_PROFILE_USE
+FAIL: gcc.dg/tree-prof/pr97461.c execution,    -fprofile-generate
-D_PROFILE_GENERATE
+UNRESOLVED: gcc.dg/tree-prof/pr97461.c execution,    -fprofile-use
-D_PROFILE_USE

The first failure is a regression, the second test is new from 

commit 00d79dc4be0b86ec564cfa2b32c47de6c07449e6
Author: Martin Liska <mli...@suse.cz>
Date:   Wed Jan 13 11:17:03 2021 +0100

    gcov: use mmap pools for KVP.

The failure looks like this:

Thread 2 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 1)]
0xfeb7d464 in _malloc_unlocked () from /lib/libc.so.1
(gdb) where
#0  0xfeb7d464 in _malloc_unlocked () from /lib/libc.so.1
#1  0xfeb7d318 in do_malloc () from /lib/libc.so.1

Running the test under truss shows

[...]
mmap64(0x00000000, 131072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, 0, 0)
Err#22 EINVAL
    Incurred fault #6, FLTBOUNDS  %pc = 0xFEC546B0
      siginfo: SIGSEGV SEGV_MAPERR addr=0xFF3FFFA8
    Received signal #11, SIGSEGV [default]
      siginfo: SIGSEGV SEGV_MAPERR addr=0xFF3FFFA8

Every single mmap64 call fails with EINVAL.  According to Solaris mmap(2),
this is due to

                    MAP_ANON  was  specified,  but the file descriptor was not
                    -1.

Linux mmap(2) also documents

       MAP_ANONYMOUS
              The mapping is not backed by any file; its contents are initial-
              ized  to zero.  The fd argument is ignored; however, some imple-
              mentations require fd to be -1 if MAP_ANONYMOUS (or MAP_ANON) is
              specified,  and  portable  applications should ensure this.  The

and indeed changing the fd arg in the mmap call to -1 lets the tests PASS.

However, I believe there's more: imagine the mmap calls fails for other
reasons: I don't think the code should simply SEGV then, but I didn't easily
see where to do proper error handling for this case.

Reply via email to