I came across this issue whilst working on getting Valgrind to work. When Valgrind runs, the guest application is loaded by Valgrind rather than the usual FreeBSD mechanisms. Thus Valgrind will synthesize an auxv, mmap rtld and run the rtld text in Valgrind's JIT compiled virtual CPU. However, to avoid memory space issues between the host and the guest, Valgrind does not provide auxv entries that contain pointers. This includes PAGESIZES. Normally rtld obtains the pagesizes from auxv, but it has fallback code to use syscalls. This works OK for an amd64 exe on an amd64 kernel and i386 on i386. But there is a problem for i386 on amd64. The i386 application will see MAXPAGESLEN as 3 from the amd64 headers. But the i386 kernel sees this as only 2 [I might have gotten this the wrong way around]. The sysctl copy out code sees this discrepancy and sets ENOMEM and the application terminates without finishing the execution of rtld. (I analysed all this with dtrace and looking at the source code, I don't know how to use gdb/lldb to step through rtld code).
Please test this https://reviews.freebsd.org/D24737
A commit references this bug: Author: kib Date: Sat May 9 13:00:39 UTC 2020 New revision: 360845 URL: https://svnweb.freebsd.org/changeset/base/360845 Log: Avoid spurious ENOMEMs from sysctl hw.pagesizes. Reported by: Paul Floyd <paulf@free.fr> PR: 246215 Reviewed by: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D24737 Changes: head/sys/kern/kern_mib.c
A commit references this bug: Author: kib Date: Sat May 16 09:03:18 UTC 2020 New revision: 361108 URL: https://svnweb.freebsd.org/changeset/base/361108 Log: MFC r360845: Avoid spurious ENOMEMs from sysctl hw.pagesizes. PR: 246215 Changes: _U stable/12/ stable/12/sys/kern/kern_mib.c
A commit references this bug: Author: kib Date: Sat May 16 09:40:18 UTC 2020 New revision: 361109 URL: https://svnweb.freebsd.org/changeset/base/361109 Log: MFC r360845: Avoid spurious ENOMEMs from sysctl hw.pagesizes. PR: 246215 Changes: _U stable/11/ stable/11/sys/kern/kern_mib.c
Assign to committer.