fix panic sleeping threads (fix from ptx_iic)
fix goto out_err