Skip to content

Commit 926cbdd

Browse files
authored
[sanitizer_common] child_stdin_fd_ should only be set on posix_spawn path (llvm#171508)
llvm#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: https://github.com/llvm/llvm-project/blob/7f5ed91684c808444ede24eb01ad9af73b5806e5/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp#L525-L535 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 llvm#170809 only truly affects Darwin.
1 parent 8f3c8da commit 926cbdd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ bool SymbolizerProcess::StartSymbolizerSubprocess() {
176176
internal_close(outfd[1]);
177177
return false;
178178
}
179+
180+
// We intentionally hold on to the read-end so that we don't get a SIGPIPE
181+
child_stdin_fd_ = outfd[0];
182+
179183
# else // SANITIZER_APPLE
180184
UNIMPLEMENTED();
181185
# endif // SANITIZER_APPLE
@@ -192,9 +196,6 @@ bool SymbolizerProcess::StartSymbolizerSubprocess() {
192196
input_fd_ = infd[0];
193197
output_fd_ = outfd[1];
194198

195-
// We intentionally hold on to the read-end so that we don't get a SIGPIPE
196-
child_stdin_fd_ = outfd[0];
197-
198199
CHECK_GT(pid, 0);
199200

200201
// Check that symbolizer subprocess started successfully.

0 commit comments

Comments
 (0)