Fixed an issue where debug callback fails when there is no callback function registered or lua env changed.