-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OpenMP] [Flang] Resolved Issue #76121: Implemented Check for Unhandl…
…ed Arguments in __kmpc_fork_call_if (#82221) Root cause: Segmentation fault is caused by null pointer dereference inside the __kmpc_fork_call_if function at https://github.com/llvm/llvm-project/blob/main/openmp/runtime/src/z_Linux_asm.S#L1186 . __kmpc_fork_call_if is missing case to handle argc=0 . Fix: Added a check inside the __kmp_invoke_microtask function to handle the case when argc is 0. --------- Co-authored-by: Singh <chasingh@amd.com>
- Loading branch information
1 parent
666970c
commit 2a57657
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// RUN: %libomp-compile && %t | FileCheck %s | ||
|
||
#include <stdio.h> | ||
#include <omp.h> | ||
|
||
typedef int32_t kmp_int32; | ||
typedef void *ident_t; | ||
typedef void *kmpc_micro; | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
extern void __kmpc_fork_call_if(ident_t *loc, kmp_int32 argc, | ||
kmpc_micro microtask, kmp_int32 cond, | ||
void *args); | ||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
// Microtask function for parallel region | ||
void microtask(int *global_tid, int *bound_tid) { | ||
// CHECK: PASS | ||
if (omp_in_parallel()) { | ||
printf("FAIL\n"); | ||
} else { | ||
printf("PASS\n"); | ||
} | ||
} | ||
|
||
int main() { | ||
// Condition for parallelization (false in this case) | ||
int cond = 0; | ||
// Call __kmpc_fork_call_if | ||
__kmpc_fork_call_if(NULL, 0, microtask, cond, NULL); | ||
return 0; | ||
} |