Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add better support for decoding different ISAs in different standalone tool threads #6690

Open
derekbruening opened this issue Mar 5, 2024 · 1 comment

Comments

@derekbruening
Copy link
Contributor

As documented at https://dynamorio.org/API_BT.html#sec_isa, each instr_t has its own ISA mode for
encoding. However, for decoding, the dcontext's ISA mode is used, and instandalone mode we have
just the global dcontext which uses a global ISA mode var. Thus, there is not good support for
a standalone tool that wanted to decode multiple ISA modes in separate tool threads.

One possibility would be to honor the ISA mode set in the instr_t passed for decoding, for decoding
routines that take an instr (so this would not help something like decode_sizeof).

Another possibility would be to use toolchain TLS support to create per-thread dcontext_t instances
in standalone mode, which would give us lock-free local heap for non-STATIC_LIBRARY for thread-private
objects.

edeiana added a commit that referenced this issue Mar 6, 2024
Documents the fact that standalone dcontext_t is not
fully thread-safe, hence parallel analysis tools should be
aware that when different threads set DR ISA mode at the same time
a race condition happens.

Issue #6690
@derekbruening
Copy link
Contributor Author

derekbruening commented Mar 6, 2024

Looks like we have a pre-existing bug on the multi-dcontext solution: #1595. It points at the AArch32 global decode_state_t and encode_state_t used for GLOBAL_DCONTEXT: so for AArch32, encoding is problematic as well as decoding and both have races even without switching ISA modes.

edeiana added a commit that referenced this issue Mar 8, 2024
Documents the fact that standalone dcontext_t is not fully thread-safe,
hence parallel analysis tools should be aware that when different
threads set DR ISA mode at the same time a race condition happens.

Issue #6690 #1595
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant