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

[OpenMP] [Flang] Program crashes at runtime with Segmentation fault when OMP PARALLEL DO IF(.false.) is encountered #76121

Closed
chandankds opened this issue Dec 21, 2023 · 3 comments

Comments

@chandankds
Copy link
Contributor

chandankds commented Dec 21, 2023

Testcase to reproduce the issue.

PROGRAM parallel_do_if
  USE OMP_LIB
  INTEGER :: I
  INTEGER :: N = 0
  INTEGER, PARAMETER :: NI = 10
!$OMP PARALLEL DO IF(.false.) 
  DO I = 1, NI
  END DO
!$OMP END PARALLEL DO
END PROGRAM

compile: flang-new -fopenmp ./test.f90 -o if.out
Run: ./if.out

Triage: Issue introduced after #65436 . Testcase works as expected after removal of this patch.

@chandankds chandankds self-assigned this Dec 21, 2023
@github-actions github-actions bot added the flang Flang issues not falling into any other category label Dec 21, 2023
chandankds pushed a commit to chandankds/llvm-project that referenced this issue Dec 21, 2023
… Segmentation fault when OMP PARALLEL DO IF(.false.) is encountered
@chandankds
Copy link
Contributor Author

Issue introduced after #65436 hence assigning it to @shiltian

@llvmbot
Copy link
Member

llvmbot commented Feb 5, 2024

@llvm/issue-subscribers-openmp

Author: chandan singh (chandankds)

Testcase to reproduce the issue.
PROGRAM parallel_do_if
  USE OMP_LIB
  INTEGER :: I
  INTEGER :: N = 0
  INTEGER, PARAMETER :: NI = 10
!$OMP PARALLEL DO IF(.false.) 
  DO I = 1, NI
  END DO
!$OMP END PARALLEL DO
END PROGRAM

compile: flang-new -fopenmp ./test.f90 -o if.out
Run: ./if.out

Triage: Issue introduced after #65436 . Testcase works as expected after removal of this patch.

chandankds added a commit to chandankds/llvm-project that referenced this issue Feb 19, 2024
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.
chandankds added a commit to chandankds/llvm-project that referenced this issue Mar 11, 2024
chandankds added a commit to chandankds/llvm-project that referenced this issue Apr 12, 2024
Added testcase
chandankds added a commit that referenced this issue May 9, 2024
…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>
@tblah
Copy link
Contributor

tblah commented Sep 2, 2024

This looks fixed to me

@tblah tblah closed this as completed Sep 2, 2024
@EugeneZelenko EugeneZelenko removed openmp flang Flang issues not falling into any other category labels Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants