Bug 34282 - FAIL: stdlib/test-bz22786
Summary: FAIL: stdlib/test-bz22786
Status: NEW
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.44
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL: https://sourceware.org/glibc/wiki/Tes...
Keywords:
Depends on:
Blocks:
 
Reported: 2026-06-13 22:04 UTC by John David Anglin
Modified: 2026-07-27 01:13 UTC (History)
5 users (show)

See Also:
Host: hppa-unknown-linux-gnu
Target: hppa-unknown-linux-gnu
Build: hppa-unknown-linux-gnu
Last reconfirmed:
Project(s) to access:
ssh public key:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John David Anglin 2026-06-13 22:04:35 UTC
dave@mx3210:~/gnu/glibc/objdir$ make test t=stdlib/test-bz22786
make -r PARALLELMFLAGS="" -C ../glibc \
        CC="gcc -U_FILE_OFFSET_BITS -U_TIME_BITS -Werror=strict-aliasing" CXX="g++ -U_FILE_OFFSET_BITS -U_TIME_BITS -Werror=strict-aliasing" \
        cc-option-wimplicit-fallthrough="-Wimplicit-fallthrough" \
        config-cflags-mprefer-vector-width="" \
        config-cflags-signaling-nans="-fsignaling-nans" \
        cc-option-wfree-labels="-Wfree-labels" \
        cc-option-wmissing-parameter-name="-Wmissing-parameter-name" \
        enable-cet="" \
        have-static-pie="yes" \
        supported-fortify="3" \
        objdir=`pwd` test
make[1]: Entering directory '/home/dave/gnu/glibc/glibc'
make subdir=stdlib -C stdlib/ ..=../ /home/dave/gnu/glibc/objdir/stdlib/test-bz22786.out
make[2]: Entering directory '/home/dave/gnu/glibc/glibc/stdlib'
env GCONV_PATH=/home/dave/gnu/glibc/objdir/iconvdata LOCPATH=/home/dave/gnu/glibc/objdir/localedata LC_ALL=C    /home/dave/gnu/glibc/objdir/elf/ld.so.1 --library-path /home/dave/gnu/glibc/objdir:/home/dave/gnu/glibc/objdir/math:/home/dave/gnu/glibc/objdir/elf:/home/dave/gnu/glibc/objdir/dlfcn:/home/dave/gnu/glibc/objdir/nss:/home/dave/gnu/glibc/objdir/nis:/home/dave/gnu/glibc/objdir/rt:/home/dave/gnu/glibc/objdir/resolv:/home/dave/gnu/glibc/objdir/mathvec:/home/dave/gnu/glibc/objdir/support:/home/dave/gnu/glibc/objdir/misc:/home/dave/gnu/glibc/objdir/debug:/home/dave/gnu/glibc/objdir/nptl:/usr/lib/gcc/hppa-linux-gnu/15/../../../hppa-linux-gnu/:/usr/lib/gcc/hppa-linux-gnu/15/../../../hppa-linux-gnu/ /home/dave/gnu/glibc/objdir/stdlib/test-bz22786  > /home/dave/gnu/glibc/objdir/stdlib/test-bz22786.out; \
../scripts/evaluate-test.sh stdlib/test-bz22786 $? false false > /home/dave/gnu/glibc/objdir/stdlib/test-bz22786.test-result
make[2]: Leaving directory '/home/dave/gnu/glibc/glibc/stdlib'
FAIL: stdlib/test-bz22786
original exit status 1
Didn't expect signal from child: got `Segmentation fault'
make[1]: Leaving directory '/home/dave/gnu/glibc/glibc'

Start it from the beginning? (y or n) y
Starting program: /home/dave/gnu/glibc/objdir/stdlib/test-bz22786
⚠️ warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
[Attaching after process 5145 fork to child process 5146]
[New inferior 5 (process 5146)]
[Detaching after fork from parent process 5145]
[Inferior 4 (process 5145) detached]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/hppa-linux-gnu/libthread_db.so.1".

Thread 5.1 "test-bz22786" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xf9afca80 (LWP 5146)]
_wordcopy_fwd_aligned (dstp=<optimized out>, srcp=<optimized out>, len=8)
    at wordcopy.c:126
⚠️ warning: 126  wordcopy.c: No such file or directory
(gdb) bt
#0  _wordcopy_fwd_aligned (dstp=<optimized out>, srcp=<optimized out>, len=8)
    at wordcopy.c:126
#1  0xf932c28c in __GI_memcpy (dstpp=<optimized out>, srcpp=<optimized out>,
    len=<optimized out>) at memcpy.c:51
#2  0x00011594 in do_test () at test-bz22786.c:50
#3  0x000127dc in run_test_function (argc=1, argv=0x1b, config=0x0)
    at support_test_main.c:244
#4  0x0001318c in support_test_main (argc=0, argv=0x1b220, config=0xf9b01388)
    at support_test_main.c:468
#5  0x00011300 in main (argc=<optimized out>, argv=<optimized out>)
    at ../support/test-driver.c:189
(gdb) disass $pc-16,$pc+16
Dump of assembler code from 0xf9332968 to 0xf9332988:
   0xf9332968 <_wordcopy_fwd_aligned+48>:       stw r22,0(ret0)
   0xf933296c <_wordcopy_fwd_aligned+52>:       ldo c(r21),ret0
   0xf9332970 <_wordcopy_fwd_aligned+56>:       copy r31,r22
   0xf9332974 <_wordcopy_fwd_aligned+60>:       ldw c(r20),r31
=> 0xf9332978 <_wordcopy_fwd_aligned+64>:       stw r22,0(ret0)
   0xf933297c <_wordcopy_fwd_aligned+68>:       ldo 10(r21),ret0
   0xf9332980 <_wordcopy_fwd_aligned+72>:       ldw 10(r20),r22
   0xf9332984 <_wordcopy_fwd_aligned+76>:       stw r31,0(ret0)
End of assembler dump.
(gdb) p/x $ret0
$2 = 0x0
(gdb) disass
Dump of assembler code for function _wordcopy_fwd_aligned:
   0xf9332938 <+0>:     extrw,u r24,31,3,r21
   0xf933293c <+4>:     ldw 0(r25),r22
   0xf9332940 <+8>:     copy r25,r20
   0xf9332944 <+12>:    ldo -1(r21),r21
   0xf9332948 <+16>:    cmpib,>>= 6,r21,0xf93329d0 <_wordcopy_fwd_aligned+152>
   0xf933294c <+20>:    copy r26,ret0
   0xf9332950 <+24>:    ldo -4(r26),r21
   0xf9332954 <+28>:    copy r22,r31
   0xf9332958 <+32>:    ldw 4(r20),r22
   0xf933295c <+36>:    stw r31,0(ret0)
   0xf9332960 <+40>:    ldo 8(r21),ret0
   0xf9332964 <+44>:    ldw 8(r20),r31
   0xf9332968 <+48>:    stw r22,0(ret0)
   0xf933296c <+52>:    ldo c(r21),ret0
   0xf9332970 <+56>:    copy r31,r22
   0xf9332974 <+60>:    ldw c(r20),r31
=> 0xf9332978 <+64>:    stw r22,0(ret0)
Thread 4.1 "test-bz22786" hit Breakpoint 1.1, _wordcopy_fwd_aligned (dstp=0,
    srcp=111136, len=6) at wordcopy.c:49
Thread 5.1 "test-bz22786" hit Breakpoint 1.1, _wordcopy_fwd_aligned (dstp=0,
    srcp=111136, len=6) at wordcopy.c:49
(gdb) bt
#0  _wordcopy_fwd_aligned (dstp=0, srcp=111136, len=6) at wordcopy.c:49
#1  0xf932c28c in __GI_memcpy (dstpp=<optimized out>, srcpp=<optimized out>,
    len=<optimized out>) at memcpy.c:51
#2  0x00011594 in do_test () at test-bz22786.c:50
#3  0x000127dc in run_test_function (argc=1, argv=0x1b, config=0x0)
    at support_test_main.c:244
#4  0x0001318c in support_test_main (argc=0, argv=0x1b220, config=0xf9b01388)
    at support_test_main.c:468
#5  0x00011300 in main (argc=<optimized out>, argv=<optimized out>)
    at ../support/test-driver.c:189

It seems path is NULL.
Comment 1 Sam James 2026-06-14 02:39:54 UTC
Did this only start recently? The test is quite old.
Comment 2 Andreas Schwab 2026-06-14 07:43:17 UTC
This wants to allocate a blob larger than half the address space.
Comment 3 John David Anglin 2026-06-14 13:43:36 UTC
(In reply to Sam James from comment #1)
> Did this only start recently? The test is quite old.

Yes.  There were no fails as of March 17, 2026.
Comment 4 John David Anglin 2026-06-14 17:40:13 UTC
Previously, the test was unsupported:

dave@mx3210:~/gnu/glibc/objdir$ cat stdlib/test-bz22786.test-result
UNSUPPORTED: stdlib/test-bz22786
original exit status 77
dave@mx3210:~/gnu/glibc/objdir$ cat stdlib/test-bz22786.out
Repeated allocation (2147483675 bytes): Invalid argument
Comment 5 Adhemerval Zanella 2026-06-15 11:38:05 UTC
It was probably due 82d9303976c74c337ef67dda10bf08c2b28aedac, I am not sure if we should just revert or mark XFAIL on hppa. I haven't seen any failure on other 32 bits ABIs, like i386, arm, and powerpc (although I am running on 64 bit kernels).
Comment 6 dave.anglin 2026-06-15 15:27:57 UTC
On 2026-06-15 7:38 a.m., adhemerval.zanella at linaro dot org wrote:
> It was probably due 82d9303976c74c337ef67dda10bf08c2b28aedac, I am not sure if
> we should just revert or mark XFAIL on hppa. I haven't seen any failure on
> other 32 bits ABIs, like i386, arm, and powerpc (although I am running on 64
> bit kernels).

I started bisecting the fail.  You are probably correct that it's due to
82d9303976c74c337ef67dda10bf08c2b28aedac.

This is on a machine with a 64-bit kernel and 8 GB physical memory.  I'm not
sure why the malloc operation fails.  Need to investigate further.
Comment 7 John David Anglin 2026-06-15 17:53:10 UTC
In blob_repeat.c, the mmap call to fill the backing store fails and
a zero'd struct support_blob_repeat is returned from allocate_big.

  /* Fill the backing store.  */
  {
    void *ptr = mmap (target, stride_size, PROT_READ | PROT_WRITE,
                      MAP_FIXED | MAP_FILE | MAP_SHARED, fd, 0);
    if (ptr == MAP_FAILED)
      {
        int saved_errno = errno;
        xmunmap (target, total_size);
        xclose (fd);
        errno = saved_errno;
        return (struct support_blob_repeat) {};
      }

do_test () at test-bz22786.c:45
45        char *path = repeat.start;
(gdb)
47        TEST_VERIFY_EXIT (symlink (".", lnk) == 0);
(gdb) p repeat
$10 = {start = 0x0, size = 0, use_malloc = false}

This causes segv in following mempcpy.

Not sure why this mmap call fails.  In the first mmap call, total_size
is 0x8000001b.  stride_size is 0x400000 in second call.

Helge, do you think this is a kernel mmap bug?
Comment 8 John David Anglin 2026-06-15 18:41:10 UTC
Here is strace output:
[pid  3996] mmap2(NULL, 2147483675, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x78a75000
[pid  3996] getrandom("\xec\xbf\x79\xa3\xf1\x8d\x8e\x4b", 8, GRND_NONBLOCK) = 8
[pid  3996] openat(AT_FDCWD, "/tmp/support_blob_repeat-FwIwK2", O_RDWR|O_CREAT|O_EXCL, 0600) = 3
[pid  3996] unlink("/tmp/support_blob_repeat-FwIwK2") = 0
[pid  3996] fallocate(3, 0, 0, 4194304) = 0
[pid  3996] mmap2(0x78a75000, 4194304, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, 3, 0) = -1 EINVAL (Invalid argument)
[pid  3996] munmap(0x78a75000, 2147483675) = 0
[pid  3996] close(3)                    = 0
[pid  3996] symlink(".", "/tmp/bz22786.FK11i9/symlink") = 0
[pid  3996] --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} ---
[pid  3996] +++ killed by SIGSEGV +++
Comment 9 Adhemerval Zanella 2026-06-15 19:20:44 UTC
(In reply to John David Anglin from comment #8)
> Here is strace output:
> [pid  3996] mmap2(NULL, 2147483675, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS,
> -1, 0) = 0x78a75000
> [pid  3996] getrandom("\xec\xbf\x79\xa3\xf1\x8d\x8e\x4b", 8, GRND_NONBLOCK)
> = 8
> [pid  3996] openat(AT_FDCWD, "/tmp/support_blob_repeat-FwIwK2",
> O_RDWR|O_CREAT|O_EXCL, 0600) = 3
> [pid  3996] unlink("/tmp/support_blob_repeat-FwIwK2") = 0
> [pid  3996] fallocate(3, 0, 0, 4194304) = 0
> [pid  3996] mmap2(0x78a75000, 4194304, PROT_READ|PROT_WRITE,
> MAP_SHARED|MAP_FIXED, 3, 0) = -1 EINVAL (Invalid argument)

It looks like hppa is not 

> [pid  3996] munmap(0x78a75000, 2147483675) = 0
> [pid  3996] close(3)                    = 0
> [pid  3996] symlink(".", "/tmp/bz22786.FK11i9/symlink") = 0
> [pid  3996] --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR,
> si_addr=NULL} ---
> [pid  3996] +++ killed by SIGSEGV +++

(In reply to John David Anglin from comment #8)
> Here is strace output:
> [pid  3996] mmap2(NULL, 2147483675, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS,
> -1, 0) = 0x78a75000
> [pid  3996] getrandom("\xec\xbf\x79\xa3\xf1\x8d\x8e\x4b", 8, GRND_NONBLOCK)
> = 8
> [pid  3996] openat(AT_FDCWD, "/tmp/support_blob_repeat-FwIwK2",
> O_RDWR|O_CREAT|O_EXCL, 0600) = 3
> [pid  3996] unlink("/tmp/support_blob_repeat-FwIwK2") = 0
> [pid  3996] fallocate(3, 0, 0, 4194304) = 0
> [pid  3996] mmap2(0x78a75000, 4194304, PROT_READ|PROT_WRITE,
> MAP_SHARED|MAP_FIXED, 3, 0) = -1 EINVAL (Invalid argument)
> [pid  3996] munmap(0x78a75000, 2147483675) = 0
> [pid  3996] close(3)                    = 0
> [pid  3996] symlink(".", "/tmp/bz22786.FK11i9/symlink") = 0
> [pid  3996] --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR,
> si_addr=NULL} ---
> [pid  3996] +++ killed by SIGSEGV +++


It seems to be a hppa limitation due its virtually-indexed cache:

arch/parisc/kernel/sys_parisc.c:

103 static unsigned long arch_get_unmapped_area_common(struct file *filp,
104         unsigned long addr, unsigned long len, unsigned long pgoff,
105         unsigned long flags, enum mmap_allocation_direction dir)
106 {
[...]
118         do_color_align = 0;
119         if (filp || (flags & MAP_SHARED))
120                 do_color_align = 1;
121         filp_pgoff = GET_FILP_PGOFF(filp);
122
123         if (flags & MAP_FIXED) {
124                 /* Even MAP_FIXED mappings must reside within TASK_SIZE */
125                 if (TASK_SIZE - len < addr)
126                         return -EINVAL;
127
128                 if ((flags & MAP_SHARED) && filp &&
129                     (addr - shared_align_offset(filp_pgoff, pgoff))
130                                 & (SHM_COLOUR - 1))
131                         return -EINVAL;
132                 return addr;
133         }


The 'filp_pgoff' comes from the file's kernel address_space pointer (unknowable and unpredictable from userspace). I think we can harden the allocate_big to:

1. Create and fallocate the backing file first.
2. Fill it via a *non-fixed MAP_SHARED* mapping (mmap (NULL, ...)). The kernel places it at a *correctly-colored* address, which both performs the fill and reveals the color: mapping_colour = addr & (mapping_alignment-1).
3. Reserve the region over-allocated by mapping_alignment, then position its base so target % mapping_alignment == mapping_colour, trimming the head/tail slack.
4. The stride is a multiple of mapping_alignment.
Comment 10 Andreas K. Huettel 2026-07-27 00:30:53 UTC
We get a pretty similar fail on ppc32 (powermac g4), see URL...
Also 32bit BE?