Conversation
9fb46ba to
f6cb01d
Compare
|
Some examples of false positives I see with CTU running locally (had to disable that on CI for now): I don’t think this can ever happen, as Relevant code: lol, we just called Looking at a lot more of these cases, I think the analyzer does not correctly handle ownership transfer of |
| memset(l, 0, sizeof(list_t)); | ||
| return new_thing_value(l, THING_TYPE_LIST); | ||
| sentry_value_t rv = new_thing_value(l, THING_TYPE_LIST); | ||
| if (sentry_value_is_null(rv)) { |
There was a problem hiding this comment.
These cases here are interesting. Sure, new_thing_value allocates internally and can fail. But CTU can’t look through the sentry_value_is_null assertion and will still flag all of these as false positives.
There was a problem hiding this comment.
Have you checked if there are annotations that you can place sentry_value_is_null to make it understand the invariants? I'd love to take a look at this CTU failure.
There was a problem hiding this comment.
The problem why I do all the checks outside is that new_thing_value takes ownership of whatever its wrapping, but it doesn’t know how to free. Maybe with a separate function pointer argument, this becomes clearer.
There was a problem hiding this comment.
Usually, there are attributes you can put on the function to declare this behavior. Since we encode the pointers in a strange way, it's understandable that tools don't follow the path.
Let's skip this for now.
| errors = int(errors[: errors.find(b"\n")]) | ||
| if errors > 0: | ||
| pytest.fail("code-checker analysis failed") | ||
|
|
There was a problem hiding this comment.
minor: personally this function is now too big and long for me to remember all variables in scope etc and i would break this up. at this point it's not problematic though, so i don't mind.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #304 +/- ##
==========================================
- Coverage 85.20% 85.03% -0.17%
==========================================
Files 49 49
Lines 3946 3975 +29
==========================================
+ Hits 3362 3380 +18
- Misses 584 595 +11 |
| memset(l, 0, sizeof(list_t)); | ||
| return new_thing_value(l, THING_TYPE_LIST); | ||
| sentry_value_t rv = new_thing_value(l, THING_TYPE_LIST); | ||
| if (sentry_value_is_null(rv)) { |
There was a problem hiding this comment.
Have you checked if there are annotations that you can place sentry_value_is_null to make it understand the invariants? I'd love to take a look at this CTU failure.
See https://github.com/Ericsson/codechecker
This basically is a frontend for
clang-tidyandclang-static-analyzer.