Repository navigation
windows: Fix attach hang when mapping fails - #1301
Merged
oleavr merged 2 commits intoNov 23, 2026
Merged
Conversation
When Gum.Mapper could not map the agent, its error reached inject_library_section() in its own domain. Vala only propagates Frida.Error from there, so it logged the error as uncaught and dropped the task without completing it, and attach() never returned. Report mapping failures as Frida.Error, as the Darwin backend does.
A process that has exited can still be opened by PID for as long as anyone holds a handle to it. Attaching to one went on to map the agent and failed with "Unable to allocate target memory". Check for it once the process is open, and fail the same way as for a PID that no longer exists.
Member
|
Thanks! 🙌 |
This was referenced Nov 23, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows,
attach()to a process that has exited but can still be opened never returns. The process stays openable for as long as anything holds a handle to it, which on the machine where I hit this was 10 seconds or more after it exited. frida-core logs an uncaught error and the call never completes.Cause
_frida_windows_helper_backend_inject_library_section()passes theGErrorfromgum_windows_bytes_new_from_section(),gum_mapper_new_take_blob()andgum_mapper_map()straight through. Those are inGUM_ERROR. The Vala side is declaredthrows Error, so the generated code only propagatesFRIDA_ERROR; for any other domain it logs the error as uncaught and unrefs the task without returning from it. The caller is never resumed.An exited target is one way to get there:
gum_mapper_map()cannot allocate in it. Any other mapping failure takes the same path, for example an import that cannot be resolved.Fix
Two commits:
frida_map_library_section()now reports Gum's errors asFrida.Error.NOT_SUPPORTEDwith Gum's message, the way the Darwin backend'sgum_failurepath does. This is what stops the hang.PROCESS_NOT_FOUND("Unable to find process with pid N"), the same as for a PID that no longer exists. Without this the caller is told "Unable to allocate target memory". It comes with a test,/HostSession/Windows/attach-to-exited-process, which keeps a handle to a killed process and attaches to it.Only the section (mapper) path is changed.
inject_library_file()already reports its failures asFrida.Error.Verification
Windows Server 2025 x86_64, MSVC,
--enable-tests --with-compat=disabled, new test run on its own:mainFrida-FATAL-CRITICAL: file ../src/windows/frida-helper-backend.vala: line 88: uncaught error: Unable to allocate target memory (gum-error-quark, 0). The test runner makes criticals fatal; outside it the call hangs.attach()returns an error; the test fails only on the error not beingPROCESS_NOT_FOUNDThe whole
frida-testssuite passes with both commits (187 ok, 0 not ok).Not tested: x86 and arm64 targets, MinGW builds, and builds with the mapper disabled.