Skip to content

Conversation

@ndrewh
Copy link
Contributor

@ndrewh ndrewh commented Dec 9, 2025

#170809 added the child_stdin_fd_ field on SymbolizerProcess to allow the parent process to hold on to the read in of the child's stdin pipe. This was to avoid SIGPIPE.

However, the StartSubprocess path still closes the stdin fd in the parent here:

auto file_closer = at_scope_exit([&] {
if (stdin_fd != kInvalidFd) {
internal_close(stdin_fd);
}
if (stdout_fd != kInvalidFd) {
internal_close(stdout_fd);
}
if (stderr_fd != kInvalidFd) {
internal_close(stderr_fd);
}
});

This could cause a double-close of this fd (problematic in the case of fd reuse).

This moves the child_stdin_fd_ field to only be initialized on the posix_spawn path. This should ensure #170809 only truly affects Darwin.

@llvmbot
Copy link
Member

llvmbot commented Dec 9, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Andrew Haberlandt (ndrewh)

Changes

#170809 added the child_stdin_fd_ field on SymbolizerProcess to allow the parent process to hold on to the read in of the child's stdin pipe. This was to avoid SIGPIPE.

However, the StartSubprocess path still closes the stdin fd in the parent here:

auto file_closer = at_scope_exit([&] {
if (stdin_fd != kInvalidFd) {
internal_close(stdin_fd);
}
if (stdout_fd != kInvalidFd) {
internal_close(stdout_fd);
}
if (stderr_fd != kInvalidFd) {
internal_close(stderr_fd);
}
});

This could cause a double-close of this fd (problematic in the case of fd reuse).

This moves the child_stdin_fd_ field to only be initialized on the posix_spawn path. This should ensure #170809 only truly affects Darwin.


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

1 Files Affected:

  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp (+4-3)
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 29c73e3e1cac1..ab6aee7c9fba7 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
@@ -176,6 +176,10 @@ bool SymbolizerProcess::StartSymbolizerSubprocess() {
       internal_close(outfd[1]);
       return false;
     }
+
+    // We intentionally hold on to the read-end so that we don't get a SIGPIPE
+    child_stdin_fd_ = outfd[0];
+
 #  else   // SANITIZER_APPLE
     UNIMPLEMENTED();
 #  endif  // SANITIZER_APPLE
@@ -192,9 +196,6 @@ bool SymbolizerProcess::StartSymbolizerSubprocess() {
   input_fd_ = infd[0];
   output_fd_ = outfd[1];
 
-  // We intentionally hold on to the read-end so that we don't get a SIGPIPE
-  child_stdin_fd_ = outfd[0];
-
   CHECK_GT(pid, 0);
 
   // Check that symbolizer subprocess started successfully.

@ndrewh ndrewh enabled auto-merge (squash) December 9, 2025 21:13
@ndrewh
Copy link
Contributor Author

ndrewh commented Dec 9, 2025

Auto-merging this to avoid any unintended impact to non-Darwin platforms caused by #170809

@ndrewh ndrewh merged commit 926cbdd into llvm:main Dec 9, 2025
11 of 12 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 9, 2025

LLVM Buildbot has detected a new failure on builder hip-third-party-libs-test running on ext_buildbot_hw_05-hip-docker while building compiler-rt at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/206/builds/10287

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: '../llvm-zorg/zorg/buildbot/builders/annotated/hip-tpl.py --jobs=32' (failure)
...
  File "/home/botworker/bbot/hip-third-party-libs-test/build/../llvm-zorg/zorg/buildbot/builders/annotated/hip-tpl.py", line 107, in step
    yield
  File "/home/botworker/bbot/hip-third-party-libs-test/build/../llvm-zorg/zorg/buildbot/builders/annotated/hip-tpl.py", line 84, in main
    run_command(cmake_command)
  File "/home/botworker/bbot/hip-third-party-libs-test/build/../llvm-zorg/zorg/buildbot/builders/annotated/hip-tpl.py", line 120, in run_command
    util.report_run_cmd(cmd, cwd=directory)
  File "/home/botworker/bbot/hip-third-party-libs-test/llvm-zorg/zorg/buildbot/builders/annotated/util.py", line 49, in report_run_cmd
    subprocess.check_call(cmd, shell=shell, *args, **kwargs)
  File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '-GNinja', '-B', 'TS-build', '-S', '.', '-DTEST_SUITE_EXTERNALS_DIR=/opt/botworker/llvm/External', '-DAMDGPU_ARCHS=gfx90a', '-DTEST_SUITE_SUBDIRS=External', '-DEXTERNAL_HIP_TESTS_KOKKOS=ON', '-DCMAKE_CXX_COMPILER=/opt/botworker/llvm/llvm-test-suite/bin/clang++', '-DCMAKE_C_COMPILER=/opt/botworker/llvm/llvm-test-suite/bin/clang']' returned non-zero exit status 1.
@@@STEP_FAILURE@@@
@@@BUILD_STEP build kokkos and test suite@@@
@@@HALT_ON_FAILURE@@@
Running: cmake --build TS-build --parallel --target build-kokkos
ninja: error: loading 'build.ninja': No such file or directory
['cmake', '--build', 'TS-build', '--parallel', '--target', 'build-kokkos'] exited with return code 1.
The build step threw an exception...
Traceback (most recent call last):
  File "/home/botworker/bbot/hip-third-party-libs-test/build/../llvm-zorg/zorg/buildbot/builders/annotated/hip-tpl.py", line 107, in step
    yield
  File "/home/botworker/bbot/hip-third-party-libs-test/build/../llvm-zorg/zorg/buildbot/builders/annotated/hip-tpl.py", line 92, in main
    run_command(["cmake", "--build", test_suite_build_dir, "--parallel", "--target", "build-kokkos"])
  File "/home/botworker/bbot/hip-third-party-libs-test/build/../llvm-zorg/zorg/buildbot/builders/annotated/hip-tpl.py", line 120, in run_command
    util.report_run_cmd(cmd, cwd=directory)
  File "/home/botworker/bbot/hip-third-party-libs-test/llvm-zorg/zorg/buildbot/builders/annotated/util.py", line 49, in report_run_cmd
    subprocess.check_call(cmd, shell=shell, *args, **kwargs)
  File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', 'TS-build', '--parallel', '--target', 'build-kokkos']' returned non-zero exit status 1.
@@@STEP_FAILURE@@@
@@@BUILD_STEP run kokkos test suite@@@
@@@HALT_ON_FAILURE@@@
Running: cmake --build TS-build --target test-kokkos
ninja: error: loading 'build.ninja': No such file or directory
['cmake', '--build', 'TS-build', '--target', 'test-kokkos'] exited with return code 1.
The build step threw an exception...
Traceback (most recent call last):
  File "/home/botworker/bbot/hip-third-party-libs-test/build/../llvm-zorg/zorg/buildbot/builders/annotated/hip-tpl.py", line 107, in step
    yield
  File "/home/botworker/bbot/hip-third-party-libs-test/build/../llvm-zorg/zorg/buildbot/builders/annotated/hip-tpl.py", line 98, in main
    run_command(["cmake", "--build", test_suite_build_dir, "--target", "test-kokkos"])
  File "/home/botworker/bbot/hip-third-party-libs-test/build/../llvm-zorg/zorg/buildbot/builders/annotated/hip-tpl.py", line 120, in run_command
    util.report_run_cmd(cmd, cwd=directory)
  File "/home/botworker/bbot/hip-third-party-libs-test/llvm-zorg/zorg/buildbot/builders/annotated/util.py", line 49, in report_run_cmd
    subprocess.check_call(cmd, shell=shell, *args, **kwargs)
  File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', 'TS-build', '--target', 'test-kokkos']' returned non-zero exit status 1.
@@@STEP_FAILURE@@@
Step 8 (update llvm-test-suite) failure: update llvm-test-suite (failure)
@@@BUILD_STEP update llvm-test-suite@@@
Running: git reset --hard origin/main
HEAD is now at 01a5e95d8 [Fortran] disable cray_poitners_10.f90 (#311)
Running: git pull
fatal: unable to access 'https://github.com/llvm/llvm-test-suite.git/': SSL connection timeout
['git', 'pull'] exited with return code 1.
The build step threw an exception...
Traceback (most recent call last):
  File "/home/botworker/bbot/hip-third-party-libs-test/build/../llvm-zorg/zorg/buildbot/builders/annotated/hip-tpl.py", line 107, in step
    yield
  File "/home/botworker/bbot/hip-third-party-libs-test/build/../llvm-zorg/zorg/buildbot/builders/annotated/hip-tpl.py", line 55, in main
    run_command(["git", "pull"])
  File "/home/botworker/bbot/hip-third-party-libs-test/build/../llvm-zorg/zorg/buildbot/builders/annotated/hip-tpl.py", line 120, in run_command
    util.report_run_cmd(cmd, cwd=directory)
  File "/home/botworker/bbot/hip-third-party-libs-test/llvm-zorg/zorg/buildbot/builders/annotated/util.py", line 49, in report_run_cmd
    subprocess.check_call(cmd, shell=shell, *args, **kwargs)
  File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['git', 'pull']' returned non-zero exit status 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants