Skip to content

[OpenMP] Fix issue of indirect function call in __kmpc_fork_call_if #65436

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

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions openmp/runtime/src/kmp_csupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ Perform a fork only if the condition is true.
void __kmpc_fork_call_if(ident_t *loc, kmp_int32 argc, kmpc_micro microtask,
kmp_int32 cond, void *args) {
int gtid = __kmp_entry_gtid();
int zero = 0;
if (cond) {
if (args)
__kmpc_fork_call(loc, argc, microtask, args);
Expand All @@ -352,10 +351,29 @@ void __kmpc_fork_call_if(ident_t *loc, kmp_int32 argc, kmpc_micro microtask,
} else {
__kmpc_serialized_parallel(loc, gtid);

#ifdef OMPT_SUPPORT
void *exit_frame_ptr;
#endif

if (args)
microtask(&gtid, &zero, args);
__kmp_invoke_microtask(VOLATILE_CAST(microtask_t) microtask, gtid,
/*npr=*/0,
/*argc=*/1, &args
#ifdef OMPT_SUPPORT
,
&exit_frame_ptr
#endif
);
else
microtask(&gtid, &zero);
__kmp_invoke_microtask(VOLATILE_CAST(microtask_t) microtask, gtid,
/*npr=*/0,
/*argc=*/0,
/*args=*/nullptr
Copy link
Contributor

Choose a reason for hiding this comment

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

@shiltian This null pointer is causing segmentation fault in one of the flang test. I am new to Openmp runtimes, Could you please share what was the intention behind using nullptr here and can it be replaced with &args ?

#ifdef OMPT_SUPPORT
,
&exit_frame_ptr
#endif
);

__kmpc_end_serialized_parallel(loc, gtid);
}
Expand Down