-
Notifications
You must be signed in to change notification settings - Fork 897
[Fix] Provided MPI_type_get_content array sizes may exceed actual ones, do not use them #13131
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
* All rights reserved. | ||
* Copyright (c) 2015 Research Organization for Information Science | ||
* and Technology (RIST). All rights reserved. | ||
* Copyright (c) 2025 BULL S.A.S. All rights reserved. | ||
* $COPYRIGHT$ | ||
* | ||
* Additional copyrights may follow | ||
|
@@ -45,7 +46,7 @@ int MPI_Type_get_contents(MPI_Datatype mtype, | |
MPI_Aint array_of_addresses[], | ||
MPI_Datatype array_of_datatypes[]) | ||
{ | ||
int rc, i; | ||
int rc, i, type_code; | ||
MPI_Datatype newtype; | ||
|
||
MEMCHECKER( | ||
|
@@ -65,6 +66,13 @@ int MPI_Type_get_contents(MPI_Datatype mtype, | |
} | ||
} | ||
|
||
/* Counts may exceed actual ones, we have no choice but to recompute them */ | ||
rc = ompi_datatype_get_args(mtype, 0, &max_integers, NULL, &max_addresses, NULL, &max_datatypes, | ||
NULL, &type_code); | ||
if (rc != MPI_SUCCESS) { | ||
OMPI_ERRHANDLER_RETURN(MPI_ERR_INTERN, MPI_COMM_WORLD, MPI_ERR_INTERN, FUNC_NAME); | ||
} | ||
|
||
Comment on lines
+70
to
+75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the point of querying the sizes if we don't act on that information? If the user told us the arrays are of a certain size and the type requires more then we should error out, raising There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This updates the user provided max lengths before passing them to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be worried about the converse: the user provides insufficient space and we write past the bounds of the user buffer. That is what I thought this patch addressed. Otherwise I don't see what this patch accomplishes. |
||
rc = ompi_datatype_get_args( mtype, 1, &max_integers, array_of_integers, | ||
&max_addresses, array_of_addresses, | ||
&max_datatypes, array_of_datatypes, NULL ); | ||
|
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.
Not sure I understand that comment: what are the
actual ones
? The count argument the user provided? Or the