Error can only be assigned once
Manually merge the segfault fix from main branch and fix several unit tests about error code