todo, stack resotration at trace exit is wrong