[compiler-rt] [sanitizer_common] [Darwin] Replace pty with pipe on posix_spawn path for spawning symbolizer (PR #170809)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 5 00:21:57 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp compiler-rt/lib/sanitizer_common/sanitizer_posix.h compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index 3810b94fe..3f8de8dd0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -281,12 +281,13 @@ int internal_sysctlbyname(const char *sname, void *oldp, uptr *oldlenp,
(size_t)newlen);
}
-bool internal_spawn(const char *argv[], const char *envp[],
- pid_t *pid, fd_t fd_stdin, fd_t fd_stdout) {
- // NOTE: Caller ensures that fd_stdin and fd_stdout are not 0, 1, or 2, since this can
- // break communication.
+bool internal_spawn(const char* argv[], const char* envp[], pid_t* pid,
+ fd_t fd_stdin, fd_t fd_stdout) {
+ // NOTE: Caller ensures that fd_stdin and fd_stdout are not 0, 1, or 2, since
+ // this can break communication.
//
- // NOTE: Caller is responsible for closing fd_stdin after the process has died.
+ // NOTE: Caller is responsible for closing fd_stdin after the process has
+ // died.
int res;
auto fd_closer = at_scope_exit([&] {
@@ -298,7 +299,8 @@ bool internal_spawn(const char *argv[], const char *envp[],
// File descriptor actions
posix_spawn_file_actions_t acts;
res = posix_spawn_file_actions_init(&acts);
- if (res != 0) return false;
+ if (res != 0)
+ return false;
auto acts_cleanup = at_scope_exit([&] {
posix_spawn_file_actions_destroy(&acts);
@@ -308,12 +310,14 @@ bool internal_spawn(const char *argv[], const char *envp[],
posix_spawn_file_actions_adddup2(&acts, fd_stdout, STDOUT_FILENO) ||
posix_spawn_file_actions_addclose(&acts, fd_stdin) ||
posix_spawn_file_actions_addclose(&acts, fd_stdout);
- if (res != 0) return false;
+ if (res != 0)
+ return false;
// Spawn attributes
posix_spawnattr_t attrs;
res = posix_spawnattr_init(&attrs);
- if (res != 0) return false;
+ if (res != 0)
+ return false;
auto attrs_cleanup = at_scope_exit([&] {
posix_spawnattr_destroy(&attrs);
@@ -322,13 +326,15 @@ bool internal_spawn(const char *argv[], const char *envp[],
// In the spawned process, close all file descriptors that are not explicitly
// described by the file actions object. This is Darwin-specific extension.
res = posix_spawnattr_setflags(&attrs, POSIX_SPAWN_CLOEXEC_DEFAULT);
- if (res != 0) return false;
+ if (res != 0)
+ return false;
// posix_spawn
char **argv_casted = const_cast<char **>(argv);
char **envp_casted = const_cast<char **>(envp);
res = posix_spawn(pid, argv[0], &acts, &attrs, argv_casted, envp_casted);
- if (res != 0) return false;
+ if (res != 0)
+ return false;
return true;
}
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_posix.h
index 259388da3..063408b83 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix.h
@@ -67,7 +67,8 @@ uptr internal_ptrace(int request, int pid, void *addr, void *data);
uptr internal_waitpid(int pid, int *status, int options);
int internal_fork();
-bool internal_spawn(const char *argv[], const char *envp[], pid_t *pid, fd_t stdin, fd_t stdout);
+bool internal_spawn(const char* argv[], const char* envp[], pid_t* pid,
+ fd_t stdin, fd_t stdout);
int internal_sysctl(const int *name, unsigned int namelen, void *oldp,
uptr *oldlenp, const void *newp, uptr newlen);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp
index eaedb8679..8ee0e23e8 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp
@@ -476,7 +476,7 @@ const char *LLVMSymbolizer::FormatAndSendCommand(const char *command_prefix,
return symbolizer_process_->SendCommand(buffer_);
}
-SymbolizerProcess::SymbolizerProcess(const char *path, bool use_posix_spawn)
+SymbolizerProcess::SymbolizerProcess(const char* path, bool use_posix_spawn)
: path_(path),
input_fd_(kInvalidFd),
output_fd_(kInvalidFd),
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
index 44cb1ae0c..29c73e3e1 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
@@ -167,7 +167,8 @@ bool SymbolizerProcess::StartSymbolizerSubprocess() {
if (use_posix_spawn_) {
# if SANITIZER_APPLE
- bool success = internal_spawn(argv, const_cast<const char **>(GetEnvP()), &pid, outfd[0], infd[1]);
+ bool success = internal_spawn(argv, const_cast<const char**>(GetEnvP()),
+ &pid, outfd[0], infd[1]);
if (!success) {
Report("WARNING: failed to spawn external symbolizer (errno: %d)\n",
errno);
``````````
</details>
https://github.com/llvm/llvm-project/pull/170809
More information about the llvm-commits
mailing list