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

Take function prototypes seriously #694

Closed
Gnimuc opened this issue Dec 19, 2022 · 1 comment · Fixed by #695
Closed

Take function prototypes seriously #694

Gnimuc opened this issue Dec 19, 2022 · 1 comment · Fixed by #695

Comments

@Gnimuc
Copy link
Contributor

Gnimuc commented Dec 19, 2022

MPI_Type_delete_attr_function is a function prototype, not a function pointer.

The type of type_delete_attr_fn is a function pointer(MPI_Type_delete_attr_function *). MPI_Type_delete_attr_function is a function prototype used for declaring this pointer.

int MPI_Type_create_keyval(MPI_Type_copy_attr_function *type_copy_attr_fn,
             MPI_Type_delete_attr_function *type_delete_attr_fn,
             int *type_keyval, void *extra_state)

This is the declaration of MPI_Type_delete_attr_function:

typedef int MPI_Type_delete_attr_function(MPI_Datatype datatype,
             int type_keyval, void *attribute_val, void *extra_state);

which is actually a function prototype and is generally used as a shortcut for declaring pointers.

A function pointer should be declared like this:

typedef int (MPI_Type_delete_attr_function*)(MPI_Datatype datatype,
             int type_keyval, void *attribute_val, void *extra_state);

So, the fix in #688 is not right. The root cause is that these "pointers" should not be defined as pointers(Ptr{Cvoid}).

@giordano
Copy link
Member

Given the deluge of weird and inconsistent segfaults I'm still getting (see #684 (comment) and following), I'm somewhat glad #693 wasn't enough 😁

Gnimuc added a commit to Gnimuc/MPI.jl that referenced this issue Dec 19, 2022
simonbyrne pushed a commit that referenced this issue Dec 19, 2022
* Update generated_api.jl

* Change function pointers => prototypes

ref #694

* add function pointer test

* comment comm test

Co-authored-by: t-bltg <tf.bltg@gmail.com>
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 a pull request may close this issue.

2 participants