Millisecond integer overflows

This was useful to me, maybe it will be useful to you:

2^31 – 1 = 2147483647 = highest signed 32 bit integer

2147483647 milliseconds = 24.855 days

2^32 – 1 = 4294967296 = highest unsigned 32 bit integer

4294967296 milliseconds = 49.710 days

If you are debugging a problem that has a change in behavior around 25-26 days, or at about 50 days (say for example that your product includes an automatic backup system, which gets into a loop and attempts to backup constantly if you set an interval above 25 days), one place to look is for integer overflow of a 32 bit millisecond counter somewhere.  Something like this is probably behind these two different (!) bugs in the Boeing 787 control avionics:

https://www.seattletimes.com/business/boeing-aerospace/faa-orders-787-safety-fix-reboot-power-once-in-a-while/ (reboot every 22 days -> 2^31 milliseconds)

https://www.theguardian.com/business/2015/may/01/us-aviation-authority-boeing-787-dreamliner-bug-could-cause-loss-of-control (reboot every 248 days -> 2^31 hundredths of a second)

 

 

 

Leave a comment