Until now in the dynamic core, the trap flag was checked and handled only after IRET. But if a program turns on the trap flag using POPFD, the dynamic core ignores it and a trap interrupt won't be executed until the next IRET (which may be in another context that doesn't except a trap interrupt, which will crash the program).
I made the changes to both core_dyn_x86 and core_dynrec.
I did notice that the normal core checks for the trap flag after jmps/calls too. But I am not sure if that is necessary? In which cases the core won't be already in trap mode? Right now I implemented the check only after POPF.
Hi,
Is there a specific game or application that is affected by this ? (for easy testing)
Yes, but that game is Windows 98 game (Hugo: The Evil Mirror), so I know that this is out of the scope of this project. (I submitted a fix to dosbox-x fork too with a bit more info on debugging this bug, but since it is a bug in the cpu emulation, I thought it will be worth fixing here too)
So to help with testing on vanilla dosbox I took the Second Reality - Future Crew demo which uses the trap flag with IRET, and switched one of those IRETs to RETF POPF.
This is the patch:
Without this fix, this program works only in normal core, not in dynamic core,