Skip to content

Conversation

@Rohankaf
Copy link

Description

This PR fixes issue #3460, where IfElseRuntime caused Frida ASAN instrumentation to stop working.

Root Cause

IfElseRuntime only executed init() and deinit() for the selected branch.
However, Frida-based runtimes — especially AsanRuntime — rely on init_all() to register:

  • ASAN shadow memory mappings
  • Frida instrumentation hooks
  • coverage mapping callbacks
  • comparison logging hooks

When asan was wrapped inside IfElseRuntime, these hooks were never registered, causing ASAN to silently fail.

Fix

This PR updates the implementation so that:

  • init() calls init_all() for both if_runtimes and else_runtimes
  • deinit() calls deinit_all() for both runtime branches

pre_exec() and post_exec() remain conditional (intended behavior).

This ensures that all runtimes correctly register their instrumentation during initialization, even when wrapped in IfElseRuntime.

Result

This now works exactly as expected:

IfElseRuntime::new(move || Ok(true), tuple_list!(asan), tuple_list!());

And behaves identically to using asan directly, restoring ASAN crash detection and shadow checks.

This fully resolves #3460.


Checklist

  • I have run ./scripts/precommit.sh and addressed all comments
  • I verified the modified code compiles
  • The fix is isolated to the IfElseRuntime implementation

@s1341
Copy link
Collaborator

s1341 commented Nov 26, 2025

Thansk for the PR, but please do NOT use AI to write your PR messages.

@Rohankaf
Copy link
Author

Rohankaf commented Nov 26, 2025

hey @s1341 Note: CI failures appear unrelated to this PR.
All errors are coming from libafl_libfuzzer_runtime and tinyinst_simple, neither of which are touched by this change. The modified code affects only crates/libafl_frida/src/helper.rs. These failures are already present on main , what should i do ?

@domenukk
Copy link
Member

domenukk commented Nov 27, 2025

This fix makes no sense, if the runtime is not enabled it doesn't need to be initialized, right?

@domenukk domenukk closed this Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants