clean call app context flags not supported outside insertion phase

13 views
Skip to first unread message

Mohammad Ewais

unread,
Dec 19, 2025, 6:15:48 PM (9 days ago) Dec 19
to DynamoRIO Users
Hello,

I had a client created with DR 8.0.0-1 about two years ago. Been using it just fine. However, had to move to a system with a lib newer than 2.35, so now I am forced to update to a newer DR as well. I am now testing with the latest 11.3.0-1.

I have a lot of dr_insert_clean_call. Most of them were inserted in drmgr_register_bb_app2app_event and drmgr_register_bb_instru2instru_event callbacks. They were working fine before, but now are giving me the error "clean call app context flags not supported outside insertion phase".

Most of the clean called functions do not have any use of dr_get_mcontext except for 3 of them. I moved those three to drmgr_register_bb_instrumentation_event instead. But I am still getting the same error!
I managed to track it down with gdb, and the clean call in question gets to function drreg_event_clean_call_insertion with the flags (DR_CLEANCALL_READS_APP_CONTEXT | DR_CLEANCALL_WRITES_APP_CONTEXT) and still causes it to break. I am 100% sure that the clean call function (and every function called inside it) doesn't read or write app context (at least not explicitly through dr_get_mcontext  and the like).

My question is, what causes these two flags to be set? Other than dr_get_mcontext? How do I debug this further?

Enrico Deiana

unread,
Dec 22, 2025, 12:04:33 AM (6 days ago) Dec 22
to DynamoRIO Users
As documented here: https://dynamorio.org/dr__defines_8h.html#af1b1bc23c42ffb7452568176b09b1212 DR_CLEANCALL_READS_APP_CONTEXT and DR_CLEANCALL_WRITES_APP_CONTEXT are passed to callbacks registered with dr_register_clean_call_insertion_event(), which "Registers a callback function that is invoked whenever a clean call is inserted in instrumentation, such as by dr_insert_clean_call() [...]" (https://dynamorio.org/dr__events_8h.html#abfbfebb6df4c756bb9e4c2a9cac82ce9).

You are probably using drreg_init(), which registers drreg_event_clean_call_insertion() (where you get the error) using dr_register_clean_call_insertion_event().

Clean calls should generally be in drmgr_register_bb_instrumentation_event().
drmgr_register_bb_app2app_event() is for modifying application code (i.e., non-meta instructions except for labels), while drmgr_register_bb_instru2instru_event() is for optimizing previously inserted instrumentation (though you can have clean calls here).

From the original message is unclear which of the many dr_insert_clean_call() in your client is causing the issue.

Reply all
Reply to author
Forward
0 new messages