-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
clang-15: May produce invalid code when -O1 (or higher) is used with -fzero-call-used-regs=all #57692
Comments
This was found when building openssh-9.0 (gentoo version: 9.0_p1-r3) with clang-15. After building openssh, utilities such as ssh-keygen started segfaulting as described above. Additionally, |
CC @isanbard |
…l-used-regs=all Bug: llvm/llvm-project#57692 Bug: https://bugs.gentoo.org/869839 Signed-off-by: Sam James <sam@gentoo.org>
@efriedma-quic @isanbard Is this something that we should fix before 15.0.1? That window is closing quickly. |
@tru By the way, OpenSSH uses this by default when the argument is available, unless --without-hardening is passed. So it's not just user-inflicted pain (even if that should work too). |
It looks like this flag was only added in LLVM 15 via https://reviews.llvm.org/D110869. |
So this is how the used zeroing sequence looks like:
This looks very wrong to me, because it includes a whole bunch of callee-saved registers. In this case |
I believe the problem is that llvm-project/llvm/lib/CodeGen/PrologEpilogInserter.cpp Lines 1276 to 1279 in 63d1d37
|
Candidate patch: https://reviews.llvm.org/D133946 |
@nvinson, @thesamesam, could you test whether this patch fixes OpenSSH? |
/cherry-pick b430980 |
/branch llvm/llvm-project-release-prs/issue57692 |
…PR57692) Callee save registers must be preserved, so -fzero-call-used-regs should not be zeroing them. The previous implementation only did not zero callee save registers that were saved&restored inside the function, but we need preserve all of them. Fixes llvm/llvm-project#57692. Differential Revision: https://reviews.llvm.org/D133946 (cherry picked from commit b430980)
/pull-request llvm/llvm-project-release-prs#159 |
The issues I originally saw with openssh is that I couldn't log in and the ssh-keygen utility would crash when run. I've rebuilt llvm with the patch and rebuilt openssh. I wasable to log in via ssh after rebuilding and the ssh-keygen utility ran correctly. This patch solves the problems I was seeing with openssh. |
…PR57692) Callee save registers must be preserved, so -fzero-call-used-regs should not be zeroing them. The previous implementation only did not zero callee save registers that were saved&restored inside the function, but we need preserve all of them. Fixes llvm/llvm-project#57692. Differential Revision: https://reviews.llvm.org/D133946 (cherry picked from commit b430980)
…PR57692) Callee save registers must be preserved, so -fzero-call-used-regs should not be zeroing them. The previous implementation only did not zero callee save registers that were saved&restored inside the function, but we need preserve all of them. Fixes llvm/llvm-project#57692. Differential Revision: https://reviews.llvm.org/D133946 (cherry picked from commit b4309800e9dc53a84222a6b57c8615d4a3084988)
…PR57692) Callee save registers must be preserved, so -fzero-call-used-regs should not be zeroing them. The previous implementation only did not zero callee save registers that were saved&restored inside the function, but we need preserve all of them. Fixes llvm/llvm-project#57692. Differential Revision: https://reviews.llvm.org/D133946
This report is copied from https://bugs.gentoo.org/869839
Description:
When building binaries using
-O1
(or higher) and the-fzero-call-used-regs=all
the resultant object files may create a broken binary when linked to.Reproducible:
Always
Steps to Reproduce:
get_progname.c
get_progname.c
:clang -O1 -ggdb -fzero-call-used-regs=all -c get_progname.c
test.c
test.c
:clang -O1 -ggdb -fzero-call-used-regs=all -c test.c
clang -o test test.o get_progname.o
./test
Actual Results:
./test
segfaults due toargv[0]
being incorrectly set toNULL
during executionExpected Results:
./test
should run and exit successfully.Additional Info:
The text was updated successfully, but these errors were encountered: