Aussie AI
Runtime Portability Glitches
-
Book Excerpt from "Generative AI in C++"
-
by David Spuler, Ph.D.
Runtime Portability Glitches
A bug that occurs on every platform is just that: a bug. A portability glitch is one with different behavior on different platforms. Some examples of the types that can occur:
- The code doesn't compile on a platform.
- The code has different results on different platforms.
- Sluggish processing on one platform.
- Crashes, hangs, or spins on one platform.
Some other types of weird problems that might indicate a portability glitch:
- Code runs fine in normal mode, but fails when the optimizer is enabled, or if the optimization level is increased.
- Code crashes in production, but runs just fine in the debugger (i.e. cannot reproduce it).
- Code intermittently fails (e.g., it could be a race condition or other timing issue.)
A lot of these types of symptoms are screaming “memory error!” And indeed, that's got to be top of the list. You might want to run your memory debugging tools again (e.g. Valgrind), even on a different platform to the one that's crashing.
However, it's not always memory or pointers. There are various other insidious bugs that can cause weird behavior in the 0.001% of cases where it's not a memory glitch:
- Uninitialized variables or object members.
- Numeric overflow or underflow (of integers or
float
type). - Data size problems (e.g. 16-bit, 32-bit, or 64-bit).
- Undefined language features. Your code might be relying on something that isn't actually guaranteed in C++.
• Next: • Up: Table of Contents |
The new AI programming book by Aussie AI co-founders:
Get your copy from Amazon: Generative AI in C++ |