session: generate wrong thread errors instead of crashing