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

data races reported when using DR for decoding without explicit dr_standalone_init #6002

Open
derekbruening opened this issue Apr 25, 2023 · 1 comment

Comments

@derekbruening
Copy link
Contributor

As part of #2499 we try to support using drdecodelib, or libdynamorio.so's decode routines, without an explicit initialization call such as dr_standalone_init. However, the lazy init's gating checks and initialization ends up flagged by race detectors such as ThreadSanitizer. Some of these complaints, such as about the standalone_library variable itself, are less concerning on x86 where acquire-release semantics are the default; but on arm they do point out real potential issues.

Here are the complaints:

In the triggers for auto-calling standalone_init:

  • standalone_library (should be changed to use explicit acquire-release)
  • heapmgt->global_heap_writable (should be replaced by dynamo_heap_initialized using acquire-release)
  • heapmgt (ditto)

Things initialized:

  • initexit_isa_mode (for this one the initializer is now static so we can remove the code writing it in d_r_decode_init)
  • cpu_info: proc_init() vs proc_get_vendor() during decoding

For moving to acquire-release: we have ATOMIC_1BYTE_WRITE and atomic_read_bool. The write on x86 is overkill for release, using xchg: but that ends up being a benefit as it satisfies ThreadSanitizer.

Xref #2502 on other lockless issues on arm.

Xref #1409 on refactoring DR code: we can probably remove some of the initialization for standalone mode. It would be nice to remove DR heap initialization: but we can't easily invoke malloc for non-STATIC_LIBRARY.

@derekbruening
Copy link
Contributor Author

These errors are reported on the invariant_checker drmemtrace tool. Having it explicitly call dr_standalone_init() eliminates the errors so we could put that in as a workaround.

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

No branches or pull requests

1 participant