-
-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: Run analysis using CodeChecker #304
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 |
@@ -308,7 +308,11 @@ sentry_value_new_list(void) | |||
list_t *l = SENTRY_MAKE(list_t); | |||
if (l) { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
@@ -308,7 +308,11 @@ sentry_value_new_list(void) | |||
list_t *l = SENTRY_MAKE(list_t); | |||
if (l) { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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-tidy
andclang-static-analyzer
.