Open Quuxplusone opened 5 years ago
Attached scantest.c
(572 bytes, text/x-csrc): Test program to reproduce false positive
This doesn't look like a regression; i can reproduce the problem on 8.0 (as
well as on 7.1).
In this specific example the problem is that we ignore the global initializer,
even though we're in main(). This would have been the valid behavior in other
cases, but it's usually incorrect in main(). I guess we should fix that. If i
turn the queue into a local variable the false positive disappears.
The bigger problem, however, is that even if it's not main(), there's no way
for us to infer that the doubly linked list is *initially* well-formed. There's
also no way for you to communicate it back to us with various forms of
assertions or annotations (partially because such assertions are impossible to
write, partially because even the simple ones, such as
assert(TAILQ_EMPTY(&head)), will most likely be unsupported due to how aliasing
isn't working correctly when discovered through comparisons).
So the action items here are:
- Maybe add explicit modeling for TAILQ etc. because they are fairly popular on
various security-critical codebases.
- Trust global initializers when we're in main().
- Improve pointer aliasing tests support.
Whoops, misunderstood; i though you're saying that it's a regression from 8.0. Anyway, i can still reproduce it on 7.0.
Hi Artem,
Sorry - I should have specified more details around saying this was a "regression".
We have a number of test systems using Fedora 29 which package clang 7.0. We did not see these problems on F29. Fedora 30 packages clang 8.0 which started showing these types of errors.
-Jim
scantest.c
(572 bytes, text/x-csrc)