Re:Simple Linux kernel memory corruption bug can lead to com...
by rcxdude on Wednesday October 20, 2021 @05:50AM
(#28928757)
You would have a huge number of false positives, because if you're doing a bunch of null checking defensively you're going to be doing it redundantly a lot.
[ Parent
| on HN ]
Re:Simple Linux kernel memory corruption bug can lead to com...
by IshKebab on Wednesday October 20, 2021 @06:34AM
(#28929053)
Right, but if the compiler has proved that you don't need those null checks then you can simply remove them. If you think you do need them then it's a sign you've screwed up somewhere and should fix it!
Re:Simple Linux kernel memory corruption bug can lead to com...
by DSMan195276 on Wednesday October 20, 2021 @09:45AM
(#28930602)
The problem is that it's not that simple. A NULL check might only become redundant after various rounds of inlining and optimizing, and the same NULL check could be redundant in one usage and necessary in the other. It's also very likely that changes to other parts of the code will make a previously 'redundant' NULL check now necessary, and obviously you're unlikely to get a warning in that direction.
Re:Simple Linux kernel memory corruption bug can lead to com...
by _flux on Wednesday October 20, 2021 @06:48AM
(#28929151)
> Right, but if the compiler has proved that you don't need those null checks then you can simply remove them.
This can be the case now, but then later someone adds new code that you did need that null check.
> If you think you do need them then it's a sign you've screwed up somewhere and should fix it!
Hm, so instead of
> Wouldn't it be better to have compile errors if the compiler figures out that it can remove a null check?
you wanted the opposite: warn when a null check is there and was actually required :).
Not sure if this is a working solution either. Maybe if it was behind a macro, JUST_CHECKING_IF_NULL(x)..
Re:Simple Linux kernel memory corruption bug can lead to com...
by IshKebab on Wednesday October 20, 2021 @08:48AM
(#28930007)
Yeah sounds like the best solution is explicit checks that the compiler understands - REDUNDANT_NULL_CHECK(...), REQUIRED_NULL_CHECK(...).
I mean obviously the solution is to use a sane language but you know...