[flang-commits] [flang] [flang][runtime] Fix seg fault in intrinsic execute_command_line (PR #78126)

via flang-commits flang-commits at lists.llvm.org
Mon Jan 15 01:21:20 PST 2024


https://github.com/sihuan updated https://github.com/llvm/llvm-project/pull/78126

>From bffb8b021e1e895df07ab5b7ce75a74ee84de206 Mon Sep 17 00:00:00 2001
From: SiHuaN <liyongtai at iscas.ac.cn>
Date: Mon, 15 Jan 2024 07:50:20 +0000
Subject: [PATCH 1/2] [flang][runtime] Fix seg fault in intrinsic
 execute_command_line

---
 flang/runtime/execute.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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)

>From e3ac1a8db1fbaadb5a5010c8e28effcdb9889699 Mon Sep 17 00:00:00 2001
From: SiHuaN <liyongtai at iscas.ac.cn>
Date: Mon, 15 Jan 2024 09:21:05 +0000
Subject: [PATCH 2/2] fix more lines

---
 flang/runtime/execute.cpp | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/flang/runtime/execute.cpp b/flang/runtime/execute.cpp
index 7368f2f576519c..eedb2d322e44d4 100644
--- a/flang/runtime/execute.cpp
+++ b/flang/runtime/execute.cpp
@@ -70,8 +70,8 @@ int TerminationCheck(int status, const Descriptor *cmdstat,
     if (!cmdstat) {
       terminator.Crash("Execution error with system status code: %d", status);
     } else {
-      CheckAndStoreIntToDescriptor(cmdstat, EXECL_ERR, terminator);
-      CopyCharsToDescriptor(*cmdmsg, "Execution error");
+      StoreIntToDescriptor(cmdstat, EXECL_ERR, terminator);
+      CheckAndCopyCharsToDescriptor(cmdmsg, "Execution error");
     }
   }
 #ifdef _WIN32
@@ -86,7 +86,7 @@ int TerminationCheck(int status, const Descriptor *cmdstat,
       terminator.Crash(
           "Invalid command quit with exit status code: %d", exitStatusVal);
     } else {
-      CheckAndStoreIntToDescriptor(cmdstat, INVALID_CL_ERR, terminator);
+      StoreIntToDescriptor(cmdstat, INVALID_CL_ERR, terminator);
       CheckAndCopyCharsToDescriptor(cmdmsg, "Invalid command line");
     }
   }
@@ -95,8 +95,8 @@ int TerminationCheck(int status, const Descriptor *cmdstat,
     if (!cmdstat) {
       terminator.Crash("killed by signal: %d", WTERMSIG(status));
     } else {
-      CheckAndStoreIntToDescriptor(cmdstat, SIGNAL_ERR, terminator);
-      CopyCharsToDescriptor(*cmdmsg, "killed by signal");
+      StoreIntToDescriptor(cmdstat, SIGNAL_ERR, terminator);
+      CheckAndCopyCharsToDescriptor(cmdmsg, "killed by signal");
     }
   }
 #endif
@@ -105,8 +105,8 @@ int TerminationCheck(int status, const Descriptor *cmdstat,
     if (!cmdstat) {
       terminator.Crash("stopped by signal: %d", WSTOPSIG(status));
     } else {
-      CheckAndStoreIntToDescriptor(cmdstat, SIGNAL_ERR, terminator);
-      CopyCharsToDescriptor(*cmdmsg, "stopped by signal");
+      StoreIntToDescriptor(cmdstat, SIGNAL_ERR, terminator);
+      CheckAndCopyCharsToDescriptor(cmdmsg, "stopped by signal");
     }
   }
 #endif



More information about the flang-commits mailing list