Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[mono] CodeQL fix set #1 - #99637

#99637
Merged
kg merged 4 commits into
dotnet:maindotnet/runtime:mainfrom
kg:codeql-1kg/runtime:codeql-1Copy head branch name to clipboard
Mar 14, 2024
Merged

[mono] CodeQL fix set #1#99637
kg merged 4 commits into
dotnet:maindotnet/runtime:mainfrom
kg:codeql-1kg/runtime:codeql-1Copy head branch name to clipboard

Conversation

@kg

@kg kg commented Mar 12, 2024

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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.

Comment thread src/mono/mono/mini/aot-compiler.c Outdated
Comment thread src/mono/mono/mini/aot-compiler.c

@lambdageek lambdageek left a comment

Copy link
Copy Markdown
Member

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

kg commented Mar 14, 2024

Copy link
Copy Markdown
Contributor Author

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.