I've had the same error, although I found out what was causing it for me.
One of my rail signals with a speed limit applied was targeted for deconstruction. When a train passed into this section, the error would occur.
Screenshot of issue (imgur.com/5K6fUao)
Not sure if OP had the same problem, but thought posting this would help :)