We have a situation where our program may stop and perform cleanup if a certain activity is performed.
When this happens, the program cleans up all objects that have been created.
The problem is that one of these objects may be responsible for the activity.
This is the order of execution:
Object calls an Angelscript function
Function performs an activity that triggers cleanup
Cleanup removes the object, along with the handler for the AS call, resulting in the context being returned to the context pool
Another AS call is done to clean up the script, but this reuses the returned context, which has not been properly unprepared
All calls after this fail due to the error state.
It would be nice to be able to force a context to be reset at any point, like an abort, only Execute doesn't have to process it to abort execution.
Since the context is still marked as active, i can't call Execute again to process the abort.
Unfortunately, the context is never allowed to end execution, due to the use of a C style longjmp that skips past the call. The context is stuck in active mode, and can't be stopped.