Skip to content

Commit

Permalink
i#6690 dcontext_t standalone: update doc (#6692)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
edeiana authored Mar 8, 2024
1 parent 9591e25 commit 79b00af
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions core/lib/dr_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,21 @@ DR_API
* \warning This context cannot be used as the drcontext for a thread
* running under DR control! It is only for standalone programs that
* wish to use DR as a library of disassembly, etc. routines.
* \warning This context is not fully thread-safe as it stores some state
* (such as #dr_isa_mode_t and other fields related to AArch32 encoding
* and decoding) that is global and may be prone to data races.
* For example, having different threads use dr_set_isa_mode() to set
* different ISA modes at the same time can result in a data race.
* Furthermore, encoding and decoding of AArch32 instructions in parallel
* may also result in a data race.
* Code that uses a standalone DR context across multiple threads should
* implement its own lock/unlock mechanism to avoid such data races
* when using dr_set_isa_mode() or encoding/decoding AArch32 instructions.
* \return NULL on failure, such as running on an unsupported operating
* system version.
*/
/* TODO i#6690: Add better multi-thread standalone decoding support.
*/
void *
dr_standalone_init(void);

Expand All @@ -66,6 +78,9 @@ dr_standalone_exit(void);
/**
* Use this dcontext for use with the standalone static decoder library.
* Pass it whenever a decoding-related API routine asks for a context.
* Note that this GLOBAL_DCONTEXT is returned by dr_standalone_init();
* beware of its limitations (especially about thread-safety) described
* there.
*/
# define GLOBAL_DCONTEXT ((void *)-1)
#endif
Expand Down

0 comments on commit 79b00af

Please sign in to comment.