Skip to content

Conversation

@kg
Copy link
Member

@kg kg commented Mar 12, 2024

CodeQL flagged various places where we're dereferencing pointers that could be NULL, this PR systematically cleans some of them up via g_assert. (Note that CodeQL doesn't currently recognize g_assert as an assertion... working on that)

@kg kg added the runtime-mono specific to the Mono runtime label Mar 12, 2024
@ghost ghost added the area-VM-meta-mono label Mar 12, 2024
Comment on lines 5852 to +5854
icomparable_inst = mono_class_inflate_generic_class_checked (icomparable, &ctx, error);
mono_error_assert_ok (error); /* FIXME don't swallow the error */
g_assert (icomparable_inst);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really wish we could teach CodeQL that for some functions that have a MonoError * argument, that if is_ok (error) then the return value is non-null. Otherwise these kinds of assertions are pretty lame.

Copy link
Member

@lambdageek lambdageek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok, but I wish we could systematically fix these code patterns:

   SomeResult *result = callee(arg1, arg, error);
   mono_error_assert_ok (error); // we should get to know that result != NULL here

by adding some kind of annotation to callee.

@kg
Copy link
Member Author

kg commented Mar 14, 2024

Looks ok, but I wish we could systematically fix these code patterns:

   SomeResult *result = callee(arg1, arg, error);
   mono_error_assert_ok (error); // we should get to know that result != NULL here

by adding some kind of annotation to callee.

Yeah, I'm not sure whether there is no relevant annotation or if the annotations just aren't documented.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-VM-meta-mono runtime-mono specific to the Mono runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants