3 ms·
From the paper: "For example, a well-known security issue in the Linux kernel was produced by a compiler incorrectly assuming a pointer null check was unnecess
by mcguire 5y ago
From the paper:
"For example, a well-known security issue in the Linux kernel was produced by a compiler incorrectly assuming a pointer null check was unnecessary ([40] fig. 6) and deleting it as an optimization. Or consider this (simplified) patch report for Linux [25]: The test [for termination] in this loop: [...] was
getting completely compiled out by my gcc, 7.0.0 20160520. The result was that the loop was going beyond the end of the [...] array and giving me
a page fault [...] I strongly suspect it’s because __start_fw and __end_fw are both declared as (separate) arrays, and so gcc concludes that __start_fw can never point to __end_fw. By changing these variables from arrays to pointers, gcc can no longer assume that these are separate arrays."
Both of those sound like simple bugs in the compiler optimizer implementation, in which case they could hardly be use as examples of how the current C standard was bad.
- foxfluff 5y agoNo, they're definitely features. The removal of null pointer checks in gcc is enabled by -fdelete-null-pointer-checks and is often enabled by default.
- TazeTSchnitzel 5y agoThey aren't bugs. The C standard considers those cases to be undefined.