Skip to content
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

Patch for undefined behaviour (nullpointer reference). #26

Open
wants to merge 1 commit into
base: vlasiator-version
Choose a base branch
from

Conversation

ursg
Copy link

@ursg ursg commented May 4, 2023

For communication of empty (zero velocity blocks) Vlasiator cells, this was trying to do an AllGather of some empty arrays, but the actual Allgatherv call tried to acess &(temp_result[0]), which is technically a nullpointer dereference.

This probably wasn't causing any actual issue (because every sane compiler would optimize that away anyway), but was reported by GCC12's undefined behaviour sanitizer.

But anyway, if total_send_count is zero in the AllGather, the whole second stage of the communication can anyway be skipped, so that's how this is fixed now.

Discovered by GCC12's undefined behaviour sanitizer.
@iljah
Copy link
Contributor

iljah commented May 4, 2023

As commented above that code, this can also be fixed by using temp_result.data() instead of &(temp_result[0]) and by now c++11 is old enough for that :)
But not even trying to send anything if there's nothing to send is probably even better...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants