This commit fixes two problems. The first is that
mmap_is_attached_or_noreserve would sometimes call VirtualAlloc with
MEM_COMMIT on address ranges that were not known to have MEM_RESERVE
status. These calls could fail, causing SIGBUS to be raised
incorrectly. See
https://cygwin.com/pipermail/cygwin-developers/2024-December/012725.html
for details. Fix this by calling VirtualAlloc only on the part of the
address range that's contained in the current mmap_record.
The second problem is that the code would sometimes break out of the
main loop without knowing whether attached mappings still occur later
in the mmap_list. This could cause SIGBUS to not be raised when it
should be. Fix this by using "continue" rather than "break". For
efficiency, introduce a boolean variable "nocover" that's set to true
if we discover that the address range cannot be covered by noreserve
mmap regions.
Addresses:
https://cygwin.com/pipermail/cygwin-developers/2024-December/012725.html
Fixes: 70e476d27be8 ("* include/cygwin/version.h: Bump DLL version to
1.7.0")
Signed-off-by: Ken Brown <kbrown@cornell.edu>