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

[sanitizer_common] Don't use syscall(SYS_clone) on Linux/sparc64 #100534

Merged
merged 1 commit into from
Jul 30, 2024

Conversation

rorth
Copy link
Collaborator

@rorth rorth commented Jul 25, 2024

  SanitizerCommon-Unit :: ./Sanitizer-sparc-Test/SanitizerCommon/StartSubprocessTest

and every single test using the llvm-symbolizer FAIL on Linux/sparc64 in a very weird way: when using StartSubprocess, there's a call to internal_fork, but we never reach internal_execve. internal_fork is implemented using syscall(SYS_clone). The calling convention of that syscall already varies considerably between targets, but as documented in clone(2), SPARC again is widely different. Instead of trying to match glibc here, this patch just calls __fork.

Tested on sparc64-unknown-linux-gnu and x86_64-pc-linux-gnu.

```
  SanitizerCommon-Unit :: ./Sanitizer-sparc-Test/SanitizerCommon/StartSubprocessTest
```
and every single test using the `llvm-symbolizer` `FAIL` on Linux/sparc64
in a very weird way: when using `StartSubprocess`, there's a call to
`internal_fork`, but we never reach `internal_execve`.  `internal_fork` is
implemented using `syscall(SYS_clone)`.  The calling convention of that
syscall already varies considerably between targets, but as documented in
`clone(2)`, SPARC again is widely different.  Instead of trying to match
`glibc` here, this patch just calls `__fork`.

Tested on `sparc64-unknown-linux-gnu` and `x86_64-pc-linux-gnu`.
@llvmbot
Copy link
Member

llvmbot commented Jul 25, 2024

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

Author: Rainer Orth (rorth)

Changes
  SanitizerCommon-Unit :: ./Sanitizer-sparc-Test/SanitizerCommon/StartSubprocessTest

and every single test using the llvm-symbolizer FAIL on Linux/sparc64 in a very weird way: when using StartSubprocess, there's a call to internal_fork, but we never reach internal_execve. internal_fork is implemented using syscall(SYS_clone). The calling convention of that syscall already varies considerably between targets, but as documented in clone(2), SPARC again is widely different. Instead of trying to match glibc here, this patch just calls __fork.

Tested on sparc64-unknown-linux-gnu and x86_64-pc-linux-gnu.


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

1 Files Affected:

  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp (+6)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index 483a1042a6238..49f57b3404fbc 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -826,10 +826,16 @@ uptr internal_sigaltstack(const void *ss, void *oss) {
   return internal_syscall(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss);
 }
 
+extern "C" pid_t __fork(void);
+
 int internal_fork() {
 #    if SANITIZER_LINUX
 #      if SANITIZER_S390
   return internal_syscall(SYSCALL(clone), 0, SIGCHLD);
+#      elif SANITIZER_SPARC
+  // The clone syscall interface on SPARC differs massively from the rest,
+  // so fall back to __fork.
+  return __fork();
 #      else
   return internal_syscall(SYSCALL(clone), SIGCHLD, 0);
 #      endif

@rorth rorth added this to the LLVM 19.X Release milestone Jul 29, 2024
@rorth rorth merged commit 1c53b90 into llvm:main Jul 30, 2024
9 checks passed
@rorth
Copy link
Collaborator Author

rorth commented Jul 30, 2024

/cherry-pick 1c53b90

llvmbot pushed a commit to llvmbot/llvm-project that referenced this pull request Jul 30, 2024
…m#100534)

```
  SanitizerCommon-Unit :: ./Sanitizer-sparc-Test/SanitizerCommon/StartSubprocessTest
```
and every single test using the `llvm-symbolizer` `FAIL` on
Linux/sparc64 in a very weird way: when using `StartSubprocess`, there's
a call to `internal_fork`, but we never reach `internal_execve`.
`internal_fork` is implemented using `syscall(SYS_clone)`. The calling
convention of that syscall already varies considerably between targets,
but as documented in `clone(2)`, SPARC again is widely different.
Instead of trying to match `glibc` here, this patch just calls `__fork`.

Tested on `sparc64-unknown-linux-gnu` and `x86_64-pc-linux-gnu`.

(cherry picked from commit 1c53b90)
@llvmbot
Copy link
Member

llvmbot commented Jul 30, 2024

/pull-request #101137

banach-space pushed a commit to banach-space/llvm-project that referenced this pull request Aug 7, 2024
…m#100534)

```
  SanitizerCommon-Unit :: ./Sanitizer-sparc-Test/SanitizerCommon/StartSubprocessTest
```
and every single test using the `llvm-symbolizer` `FAIL` on
Linux/sparc64 in a very weird way: when using `StartSubprocess`, there's
a call to `internal_fork`, but we never reach `internal_execve`.
`internal_fork` is implemented using `syscall(SYS_clone)`. The calling
convention of that syscall already varies considerably between targets,
but as documented in `clone(2)`, SPARC again is widely different.
Instead of trying to match `glibc` here, this patch just calls `__fork`.

Tested on `sparc64-unknown-linux-gnu` and `x86_64-pc-linux-gnu`.
tru pushed a commit to llvmbot/llvm-project that referenced this pull request Aug 10, 2024
…m#100534)

```
  SanitizerCommon-Unit :: ./Sanitizer-sparc-Test/SanitizerCommon/StartSubprocessTest
```
and every single test using the `llvm-symbolizer` `FAIL` on
Linux/sparc64 in a very weird way: when using `StartSubprocess`, there's
a call to `internal_fork`, but we never reach `internal_execve`.
`internal_fork` is implemented using `syscall(SYS_clone)`. The calling
convention of that syscall already varies considerably between targets,
but as documented in `clone(2)`, SPARC again is widely different.
Instead of trying to match `glibc` here, this patch just calls `__fork`.

Tested on `sparc64-unknown-linux-gnu` and `x86_64-pc-linux-gnu`.

(cherry picked from commit 1c53b90)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

3 participants