Under Windows on Arm (AArch64), the function hook_or_detect_cygwin will
return NULL early, which will cause the call to real_path.set_cygexec
in av::setup to accept false as a parameter instead of true.

Afterwards, in child_info_spawn::worker the call to
child_info_spawn::set would eventually pass that false result of
real_path.iscygexec() to the child_info constructor as the boolean
variable need_subproc_ready, where the flag _CI_ISCYGWIN will be
erroneously not set.

Later in child_info_spawn::worker the failed iscygwin() flag check will
cause the "parent" process handle to become non-inheritable. This patch
fixes the non-inheritability issue by introducing a new check for the
IMAGE_FILE_MACHINE_ARM64 constant in the function PEHeaderFromHModule.

Tests fixed on AArch64:
winsup.api/signal-into-win32-api.exe
winsup.api/ltp/fcntl07.exe
winsup.api/ltp/fcntl07B.exe
winsup.api/posix_spawn/chdir.exe
winsup.api/posix_spawn/fds.exe
winsup.api/posix_spawn/signals.exe

Signed-off-by: Igor Podgainoi <[email protected]>
---
 winsup/cygwin/hookapi.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/winsup/cygwin/hookapi.cc b/winsup/cygwin/hookapi.cc
index ee2edbafe..b0126ac04 100644
--- a/winsup/cygwin/hookapi.cc
+++ b/winsup/cygwin/hookapi.cc
@@ -45,6 +45,8 @@ PEHeaderFromHModule (HMODULE hModule)
     {
     case IMAGE_FILE_MACHINE_AMD64:
       break;
+    case IMAGE_FILE_MACHINE_ARM64:
+      break;
     default:
       return NULL;
     }
-- 
2.43.0

Reply via email to