Open debohman opened 1 year ago
Removing the use of -fzero-call-used-regs
allows the project to build successfully.
I compiled this with the offending compilers and couldn't replicate the failure. That was on a Linux box though. I'm not sure if an Apple build of Clang acts subtly diffrently.
OpenSSH apparently ran into this with Clang-15. Normally, they use -fzero-call-used-regs=all
, and in the case of Clang-15, they substitute -fzero-call-used-regs=used
. Now, with Clang-17, you can't use -fzero-call-used-regs=used
either.
I tried to build the previous version of OpenSSH V_9_4_P1
, and it fails in the exact same way as V_9_5_P1
. V_9_4_P1
was previously built successfully with Clang-16.
OpenSSH apparently ran into this with Clang-15.
That was the same flag but different symptom: it generated code that had nodeterministic failures (ie the compilation was nondeterministic; some compilations produced working binaries, some produced binaries that failed but IME a given binary would behave deterministically).
OpenSSH apparently ran into this with Clang-15.
That was the same flag but different symptom: it generated code that had nodeterministic failures (ie the compilation was nondeterministic; some compilations produced working binaries, some produced binaries that failed but IME a given binary would behave deterministically).
You are correct, it is a different failure involving -fzero-call-used-regs
.
I just successfully built OpenSSH V_9_5_P1
using Clang 16.0.5
. This used -fzero-call-used-regs=all
.
Could you run creduce on the attached bad file? It might help in understanding what's going on and how I can reproduce it on my end.
I assume you are talking about creduce? I tried to build it against clang-17, and it did not build successfully.
cvise
will do the job as well.
I was able to make the project build with the following diffs:
diff --git a/ssh-ecdsa-sk.c b/ssh-ecdsa-sk.c
index 5dcd3c13d..40fe3af11 100644
--- a/ssh-ecdsa-sk.c
+++ b/ssh-ecdsa-sk.c
@@ -68,7 +68,7 @@ static void
ssh_ecdsa_sk_cleanup(struct sshkey *k)
{
sshkey_sk_cleanup(k);
- sshkey_ecdsa_funcs.cleanup(k);
+// sshkey_ecdsa_funcs.cleanup(k);
}
static int
diff --git a/ssh-ed25519-sk.c b/ssh-ed25519-sk.c
index c6bc5e72b..771b9df39 100644
--- a/ssh-ed25519-sk.c
+++ b/ssh-ed25519-sk.c
@@ -42,7 +42,7 @@ static void
ssh_ed25519_sk_cleanup(struct sshkey *k)
{
sshkey_sk_cleanup(k);
- sshkey_ed25519_funcs.cleanup(k);
+// sshkey_ed25519_funcs.cleanup(k);
}
static int
Does that help to narrow it down at all?
FYI, I am now using Clang-17.0.5
.
It would be much better to have a compilable example to work with. It's not going to fail on my machines as is, so I need to be able to step through and look at what's potentially happening. But I'll see what I can do.
Reversing the lines in the two functions compiles successfully. It may be the tail call through a function pointer.
Reversing the lines in the two functions compiles successfully. It may be the tail call through a function pointer.
Yeah, here's what I generate. (Notice that %rax
isn't modified before the tail call.) Unfortunately, in your backtrace the important information detailing where the assert is happening is missing...:-/
movq sshkey_ecdsa_funcs@GOTPCREL(%rip), %rax
.loc 1 71 2 is_stmt 0 # ssh-ecdsa-sk.c:71:2
movq %rbx, %rdi
.loc 1 71 2 epilogue_begin # ssh-ecdsa-sk.c:71:2
popq %rbx
.Ltmp2:
#DEBUG_VALUE: ssh_ecdsa_sk_cleanup:k <- $rdi
.cfi_def_cfa_offset 8
fldz
fldz
fldz
fldz
fldz
fldz
fldz
fldz
fstp %st(0)
fstp %st(0)
fstp %st(0)
fstp %st(0)
fstp %st(0)
fstp %st(0)
fstp %st(0)
fstp %st(0)
xorl %ecx, %ecx
xorl %edx, %edx
xorl %esi, %esi
xorl %r8d, %r8d
xorl %r9d, %r9d
xorl %r10d, %r10d
xorl %r11d, %r11d
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
xorps %xmm3, %xmm3
xorps %xmm4, %xmm4
xorps %xmm5, %xmm5
xorps %xmm6, %xmm6
xorps %xmm7, %xmm7
xorps %xmm8, %xmm8
xorps %xmm9, %xmm9
xorps %xmm10, %xmm10
xorps %xmm11, %xmm11
xorps %xmm12, %xmm12
xorps %xmm13, %xmm13
xorps %xmm14, %xmm14
xorps %xmm15, %xmm15
.Ltmp3:
jmpq *16(%rax) # TAILCALL
Okay. I'd appreciate it if you can do this. Run the compile command for ssh-ecdsa-sk.c
but add -mllvm -print-after-all
to it. Pipe the output into a file:
$ clang ... -mllvm -print-after-all > blob.log 2>&1
Then add it to this bug. You'll probably have to compress it first.
No problem.