Avoid null pointer in case of incorrect state

At the begining of the trace, we observed in some traces incorrect state while
the statedump occurs. If this is the case, log the error and continue.