fixed double free of per thread error state