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

[flang][runtime] Fix seg fault in intrinsic execute_command_line #78126

Merged
merged 2 commits into from
Jan 15, 2024

Conversation

sihuan
Copy link
Contributor

@sihuan sihuan commented Jan 15, 2024

Fixes #77975

@llvmbot llvmbot added flang:runtime flang Flang issues not falling into any other category labels Jan 15, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jan 15, 2024

@llvm/pr-subscribers-flang-runtime

Author: SiHuaN (sihuan)

Changes

Fixes #77975


Full diff: https://github.com/llvm/llvm-project/pull/78126.diff

1 Files Affected:

  • (modified) flang/runtime/execute.cpp (+1-1)
diff --git a/flang/runtime/execute.cpp b/flang/runtime/execute.cpp
index c327f07f5cbffe..7368f2f576519c 100644
--- a/flang/runtime/execute.cpp
+++ b/flang/runtime/execute.cpp
@@ -87,7 +87,7 @@ int TerminationCheck(int status, const Descriptor *cmdstat,
           "Invalid command quit with exit status code: %d", exitStatusVal);
     } else {
       CheckAndStoreIntToDescriptor(cmdstat, INVALID_CL_ERR, terminator);
-      CopyCharsToDescriptor(*cmdmsg, "Invalid command line");
+      CheckAndCopyCharsToDescriptor(cmdmsg, "Invalid command line");
     }
   }
 #if defined(WIFSIGNALED) && defined(WTERMSIG)

@sihuan sihuan requested a review from yi-wu-arm January 15, 2024 07:58
Copy link
Contributor

@yi-wu-arm yi-wu-arm left a comment

Choose a reason for hiding this comment

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

Thanks for providing this fix! I figure out that I had written the logic in a reversed way.
It should be StoreInt with cmdstat and CheckStoreChars with cmdmsg. Do you mind to change other lines in TerminationCheck as well?

@sihuan sihuan requested a review from yi-wu-arm January 15, 2024 09:23
Copy link
Contributor

@yi-wu-arm yi-wu-arm left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for providing this fix!

@sihuan sihuan merged commit a9309e4 into llvm:main Jan 15, 2024
4 checks passed
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:runtime flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Intrinsic "execute_command_line" results in a seg fault
3 participants