Skip to content

Commit 8f3ec11

Browse files
rorthllvmbot
authored andcommitted
[sanitizer_common] Don't use syscall(SYS_clone) on Linux/sparc64 (llvm#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)
1 parent 404746b commit 8f3ec11

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,10 +826,16 @@ uptr internal_sigaltstack(const void *ss, void *oss) {
826826
return internal_syscall(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss);
827827
}
828828

829+
extern "C" pid_t __fork(void);
830+
829831
int internal_fork() {
830832
# if SANITIZER_LINUX
831833
# if SANITIZER_S390
832834
return internal_syscall(SYSCALL(clone), 0, SIGCHLD);
835+
# elif SANITIZER_SPARC
836+
// The clone syscall interface on SPARC differs massively from the rest,
837+
// so fall back to __fork.
838+
return __fork();
833839
# else
834840
return internal_syscall(SYSCALL(clone), SIGCHLD, 0);
835841
# endif

0 commit comments

Comments
 (0)