Page MenuHomeFreeBSD

crt_malloc: Be more persistent when handling mmap() failure
ClosedPublic

Authored by kib on Oct 12 2021, 9:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jul 2, 6:06 AM
Unknown Object (File)
Wed, Jun 25, 10:53 AM
Unknown Object (File)
Fri, Jun 20, 10:30 AM
Unknown Object (File)
Tue, Jun 17, 6:44 PM
Unknown Object (File)
Sun, Jun 15, 1:42 PM
Unknown Object (File)
Jun 3 2025, 6:50 PM
Unknown Object (File)
Apr 25 2025, 5:06 AM
Unknown Object (File)
Apr 22 2025, 3:17 PM
Subscribers

Details

Summary
In the situation with limited address space, together with
fragmentation, it is possible for mmap() request in morecore() to fail
when asking for required size + NPOOLPAGES, but succeed without the
addend.  Retry allocation there.

PR:     259076
Reported by:    Denis Koreshkov <dynamic-wind@mail.ru>

Also

crt_malloc: use uintptr_t instead of long for arithmetic on addresses

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib requested review of this revision.Oct 12 2021, 9:48 PM

LGTM. roundup2 usage can be simplified but feel free to ignore that suggestion.

libexec/rtld-elf/rtld_malloc.c
264

roundup2 is now type-preserving, so you should be able to pass a caddr_t argument.

This revision is now accepted and ready to land.Oct 12 2021, 10:17 PM