fix crashing bugs in err_msg