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

r274162 (SafeStack) causes cryptographic code to miscompile #31491

Closed
EdSchouten opened this issue Mar 5, 2017 · 7 comments
Closed

r274162 (SafeStack) causes cryptographic code to miscompile #31491

EdSchouten opened this issue Mar 5, 2017 · 7 comments
Labels
bugzilla Issues migrated from bugzilla llvm:codegen

Comments

@EdSchouten
Copy link
Contributor

Bugzilla Link 32143
Resolution FIXED
Resolved on May 23, 2017 16:05
Version trunk
OS All
Blocks #31409
Attachments Reduced testcase of the miscompilation
CC @eugenis,@zmodem,@tstellar

Extended Description

CloudABI is a runtime environment based on a subset of POSIX that allows for strong sandboxing. CloudABI uses Clang as its C/C++ compiler with LLVM's SafeStack enabled by default.

One of the lead developers of Bitcoin, Wladimir van der Laan, is currently working on getting Bitcoin Core ported over to CloudABI:

https://laanwj.github.io/2017/03/02/porting-bitcoin-core-to-cloudabi.html

In the process, he discovered that some of Bitcoin's unit tests tend to fail when SafeStack is enabled. He observed this when using LLVM/Clang 4.0-rc2:

NuxiNL/cloudabi-ports#30

I've done some bisecting and discovered it's caused by SVN r274162:

270000 ok
272500 ok
273750 ok
274062 ok
274140 ok
274160 ok
274161 ok
274162 bad
274163 bad
274165 bad
274170 bad
274179 bad
274218 bad
274375 bad
275000 bad
280000 bad
296985 bad

Attached you can find a source file of a reduced test case that should build both on CloudABI and non-CloudABI. When built with SafeStack enabled and -O2 or higher set, it will call abort(). When built without SafeStack or when using lower optimisation levels, it will print "O.K." and terminate successfully.

I will add this as a blocker for 4.0.

@zmodem
Copy link
Collaborator

zmodem commented Mar 6, 2017

It sounds like the revision that regressed that was in 3.9 too, so it's not a regression and too late for 4.0. I'll change it to be a 4.0.1 blocker instead.

@tstellar
Copy link
Collaborator

Do we have a fix for this yet?

@eugenis
Copy link
Contributor

eugenis commented May 19, 2017

No. Let's just disable this optimization for now.

@tstellar
Copy link
Collaborator

No. Let's just disable this optimization for now.

Can you write a patch for this?

@eugenis
Copy link
Contributor

eugenis commented May 19, 2017

Yes, I'll do it. I'm having issues with libc++ tests right now, but I'll get to it later today.

@eugenis
Copy link
Contributor

eugenis commented May 19, 2017

Coloring disabled in r303456.

@tstellar
Copy link
Collaborator

Merged: r303687

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
tstellar added a commit that referenced this issue Mar 8, 2022
This was disabled in 2acea27 as a
work-around for Issue #31491.  I've reduced the test case from that bug
and confirmed that it is now fixed.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D120866
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla llvm:codegen
Projects
None yet
Development

No branches or pull requests

4 participants