[PATCH] elf: allow anonymous mapping in gap for tst-link-map-contiguous-ldso

Xi Ruoyao xry111@xry111.site
Mon Jan 19 11:04:15 GMT 2026


On Mon, 2026-01-19 at 11:43 +0100, Florian Weimer wrote:
> * Xi Ruoyao:
> 
> > On Mon, 2026-01-19 at 11:09 +0100, Florian Weimer wrote:
> > > * Xi Ruoyao:
> > > 
> > > > The initialization process of libc.so creates several anonymous mappings
> > > > and the kernel may lay them into the gap.  If all pages in the gap are
> > > > occupied, the test would fail.
> > > > 
> > > > The failure reproduces most frequently on LoongArch because with the
> > > > commonly used page size (16 KiB) the gap only contains 4 pages and the
> > > > probability they are all occupied is not near to zero.  With the changes
> > > > in the patch, a test run outputs:
> > > > 
> > > >     info: ld.so link map is not contiguous
> > > >     info: anonymous map found at 0x7ffff1c60000
> > > >     info: anonymous map found at 0x7ffff1c64000
> > > >     info: anonymous map found at 0x7ffff1c68000
> > > >     info: anonymous map found at 0x7ffff1c6c000
> > > 
> > > What's the actual error message from the test?
> > 
> > FAIL: elf/tst-link-map-contiguous-ldso
> > original exit status 1
> > info: ld.so link map is not contiguous
> > error: tst-link-map-contiguous-ldso.c:77: no ld.so gap found
> 
> Thanks, I understand now.  This is a clear test bug.
> 
> This means that we likely have to /proc/self/maps to maintain coverage
> and avoid the test bug. 8-( Unfortuantely, I haven't seen this reproduce
> in my testing (not even on Arm with 4K pages), so I'm not sure if I can
> work on this effectively.

On Arm with 4K pages there are more than a dozen of pages there so the
probability they are all mapped for anonymous is very low.  If using a
16K page Arm it may be easier...

I can work on this if I really understand how the test is supposed. 
Could you explain how my patch loses coverage so I can add the coverage
back by parsing /proc/self/maps (or maybe another way)?

-- 
Xi Ruoyao <xry111@xry111.site>


More information about the Libc-alpha mailing list