You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Game freezing / general robustness to wrapped game engine #161
I've noticed that when randomly sampling actions in real text games (e.g. ZMachine games not generated by TextWorld), the game inevitably freezes/segfaults at some point (It seems like Jericho has the same issue). Since TextWorld is a RL environment for text games, can we make it more robust to these problems? For example, having a timeout failure or game crashed failure?
Here's a code snippet that consistently freezes on my machine:
Thank you for reporting this issue. I'm not surprised Jericho would have the same issue since TextWorld uses Jericho under the hood. If I remember correctly, I think Matthew Hausknecht (@mhauskn) is aware of that issue but I don't know if we had a solution for it?
Hey Matthew Hausknecht (@mhauskn) , there are a variety of ways in which these failures can manifest. I haven't seen Fatal error: Illegal object from Jericho before, but I have seen segfaults.
I'm not even certain that the problem lies in Frotz. We are wrapping environments (textworld) around environments (Jericho) around environments (Frotz) around environments (ZMachine). There are probably fatal bugs in ZMachine (which is not written to support randomly behaving RL agents), and it's probably overly optimistic to hope to get those fixed. The problem for TextWorld users is that this kills the entire Python stack, which is not ideal for RL. It's probably useful to do something on the TextWorld end to handle these failure cases.
One simulator-agnostic way is to wrap the simulator (e.g. Jericho or Frotz) in a separate process, such that one can issue time-out-attached commands to the simulator. The simulator can fail/time out, but this does not affect TextWorld. When these events happen, TextWorld can just tell the user that the simulator died and the user can decide what they want to do (e.g. discard the trajectory, assign a negative reward for killing the simulator).
I've updated Jericho (now version 1.2.0) to avoid the Python stack crashing when a game encounters a fatal error. Instead the episode will be reported as over and the emulator status will be marked as halted.
This change should address the issue with Balances, but will not fix games that hang or segfault. Running your script across all supported Jericho games revealed 2 hangs and 3 fatal errors. The 3 fatal errors should be addressed by this update, but for now I'd advise avoiding the showverb command that causes hangs in the other 2 games. Please open issues with Jericho if you encounter other hangs or segfaults.
Thanks Matthew Hausknecht (@mhauskn), now I'll need to think what's the best way to expose that information in TextWorld.
Regarding the hangs, what Victor Zhong (@vzhong) proposes (wrapping a subprocess) is probably the safest way to do it but the drawback is the overhead over inter-multiprocess communications. If I remember correctly Jericho's main focus is speed.
That said, in TextWorld we are already using subprocesses that to handle communications with the git-glulx interpreter, so we could also do it for Jericho.
I'm avoiding implementing subprocess wrapping in Jericho for now. My hope is that segfaults + hangs can be fixed. If fixing segfaults/hangs turns out not to be feasible, then I may reconsider in the future. That said, I totally understand if TW wants to subprocess-wrap Jericho for added safety.
Activity
MarcCote commentedon Apr 25, 2019
Thank you for reporting this issue. I'm not surprised Jericho would have the same issue since TextWorld uses Jericho under the hood. If I remember correctly, I think Matthew Hausknecht (@mhauskn) is aware of that issue but I don't know if we had a solution for it?
mhauskn commentedon Apr 25, 2019
Here's an attempt to recreate the issue in Jericho alone:
Running this script I observe a Fatal error:
Is this consistent with what you're seeing Victor Zhong (@vzhong)?
mhauskn commentedon Apr 25, 2019
I've verified that the same behavior is present in the Frotz (the base emulator used by Jericho) and have filed an issue there (https://gitlab.com/DavidGriffith/frotz/issues/111).
It's a valid point that RL environments shouldn't hang or produce fatal errors for what should be valid actions.
vzhong commentedon Apr 26, 2019
Hey Matthew Hausknecht (@mhauskn) , there are a variety of ways in which these failures can manifest. I haven't seen
Fatal error: Illegal objectfrom Jericho before, but I have seen segfaults.I'm not even certain that the problem lies in Frotz. We are wrapping environments (textworld) around environments (Jericho) around environments (Frotz) around environments (ZMachine). There are probably fatal bugs in ZMachine (which is not written to support randomly behaving RL agents), and it's probably overly optimistic to hope to get those fixed. The problem for TextWorld users is that this kills the entire Python stack, which is not ideal for RL. It's probably useful to do something on the TextWorld end to handle these failure cases.
One simulator-agnostic way is to wrap the simulator (e.g. Jericho or Frotz) in a separate process, such that one can issue time-out-attached commands to the simulator. The simulator can fail/time out, but this does not affect TextWorld. When these events happen, TextWorld can just tell the user that the simulator died and the user can decide what they want to do (e.g. discard the trajectory, assign a negative reward for killing the simulator).
mhauskn commentedon Apr 27, 2019
I've updated Jericho (now version 1.2.0) to avoid the Python stack crashing when a game encounters a fatal error. Instead the episode will be reported as over and the emulator status will be marked as halted.
This change should address the issue with Balances, but will not fix games that hang or segfault. Running your script across all supported Jericho games revealed 2 hangs and 3 fatal errors. The 3 fatal errors should be addressed by this update, but for now I'd advise avoiding the showverb command that causes hangs in the other 2 games. Please open issues with Jericho if you encounter other hangs or segfaults.
vzhong commentedon Apr 28, 2019
Thank you Matthew Hausknecht (@mhauskn) !! I'll take a look soon
MarcCote commentedon Apr 28, 2019
Thanks Matthew Hausknecht (@mhauskn), now I'll need to think what's the best way to expose that information in TextWorld.
Regarding the hangs, what Victor Zhong (@vzhong) proposes (wrapping a subprocess) is probably the safest way to do it but the drawback is the overhead over inter-multiprocess communications. If I remember correctly Jericho's main focus is speed.
That said, in TextWorld we are already using subprocesses that to handle communications with the git-glulx interpreter, so we could also do it for Jericho.
mhauskn commentedon Apr 29, 2019
I'm avoiding implementing subprocess wrapping in Jericho for now. My hope is that segfaults + hangs can be fixed. If fixing segfaults/hangs turns out not to be feasible, then I may reconsider in the future. That said, I totally understand if TW wants to subprocess-wrap Jericho for added safety.