Repository navigation
Conversation
…ddresses Invalidating a value or computing the addresses reachable from it reads array contents at an unknown index. This is not an access by the program, but the default bounds check warned "May access array out of bounds" and set the InvalidDeref flag, e.g., whenever an unknown or library function deeply writes a struct that contains an array. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This gave me deja vu because #2022 put the whole reachability calculation under speculation, which should suppress these checks/warnings. |
|
Probably the check should be in |
Perhaps we shouldn't abuse |
Heap memory allocated via a void pointer has type void, so invalidating it passes void to invalidate_value for the contained struct and its array field. This covers the case of invalidate_value for arrays whose type is not an array type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I removed the changes to
Should we go for this in this PR? It seems like it may be a bigger rewrite. |
|
Stuff like int a[10];
a[99] = foo();where |
[Opus 5.5]:
Goblint produces spurious "May access array out of bounds" warnings when a value containing an array is invalidated or traversed for reachable addresses. For example, this happens when an unknown function, or a library function with a deep write, gets a pointer to a struct with an array member. These warnings also set the
InvalidDerefflag, sovalid-deref/valid-memsafetycannot be proven.This was because
ValueDomain.invalidate_valueand base'sreachable_from_valueread the array contents at an unknown index viaCArrays.get, which runs the out-of-bounds check by default. These reads are internal to the analysis and not accesses by the program.We fix this by passing
~checkBounds:falseto these reads, as the conversions between array domains inArrayDomainalready do. Real array accesses by the program are still checked.Tests
New regression test
26-undefined_behavior/16-invalidate-array-no-oob.c. On master it fails with the spurious warning at the call. An actual out-of-bounds write afterwards is still reported.Context
This is needed for an upcoming PR that tracks
stdin/stdout/stderras pointers to actualFILEobjects. Libc'sFILEcontains arrays, so calls likefgets(buf, n, stdin), which deep-write the stream, would otherwise trigger this warning.🤖 Generated with Claude Code