Hi,
> I understand that there is no opportunity to have a translation field referring to the original instruction if there are no app instructions in the emulation code
Even though the emulation code may not retain any original app instr, some emulation instr can still be marked as app with the translation field set. E.g., see the scatter gather expansion on x86 which removes the original scatter gather instr and emulates it with a sequence of scalar stores and loads and sets the pc of the original app instr in some of them:
https://github.com/DynamoRIO/dynamorio/blob/0ab4d54744519e01854784612a83ddc57a16b0ad/ext/drx/scatter_gather_x86.c#L293. This helps DR in restarting execution correctly if there's a signal.
> but I don't think this problem has to do with signals because the source code of the app does not refer to signals and I don't see any signals when I run it under a debugger.
Even though the app doesn't have signals, DR may still send signals for its own operation and may want to reconstruct app state. So I think it's still important to have the translation field set appropriately.
> under what circumstances do I need to set the translation field on a meta instruction and then have a restore_state callback? Is that only if my meta instruction might cause a precise signal?
I believe it is important to set the translation field even if the instr may not cause a precise signal. The assumption about no signals in the app is not true anymore for the app running under DR.
What I'm not completely sure about: I know DR tries to delay signals until we're at a safe spot (e.g., end of fragment). So is there nothing in DR's signal handling code that would try to translate app state if we're not at a safe spot?
> Sometimes it seems to work either way, and sometimes I see sporadic failures if I change the way an instruction is marked.
For the crashes you see, do you have more debug info? Where does the crash happen (in the code cache, in the middle of an emulated instr, or core DR, or your client?). Does the crash reproduce with the DR debug build, with logs enabled?
Abhinav