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
Unaligned stack with Xcode 11.0 beta #848
Comments
|
Some more details after debugging: libsodium throws a general protection fault due to an unaligned memory access in Arguments at time of unaligned access: |
|
The stack not being aligned is quite unexpected and sounds like a compiler bug. How did you compile it? What version of Xcode did you use? Any specific extra optimizations, or did you just use |
|
Meanwhile, this code path has been disabled in the stable branch. |
Just plain
No special options for
$ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version
version: 11.0.0.0.1.1563062694This is the latest beta of macOS Catalina. See also |
Disabled in stable, but not master / 0.18.0? |
|
That's exactly what stable versions are for. Can you try different optimization levels, including no optimizations at all ( |
|
I see the same results (
When compiling with |
355: Fix path to configure script r=kpp a=stv0g See #341 === jedisct1/libsodium#848 Co-authored-by: Steffen Vogel <post@steffenvogel.de>
|
o_O What other tests are failing with |
|
All fail with a segmentation fault: |
|
Try the compiler version shipped with Xcode ( |
|
I can confirm that all tests succeed when using compiler from my full Xcode installation. Here are again the versions: /Applications/Xcode.app/$ sudo xcode-select -s /Applications/Xcode.app/
$ /usr/bin/gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/binState: /Applications/Xcode-beta.app/State: /Library/Developer/CommandLineTools/State: As you can see, Xcode uses Clang 10 while my Command Line Tools use Clang 11.. o_O I am downloading now Xcode 11 Beta 4. And try again. I assume that my Command Line Tools already have been updated automatically, while Xcode stayed at version 10. |
|
Xcode 11 beta 4 ships with what Apple calls LLVM 11, but it's a different version than the one you reported. |
|
I updated my previous comment with results using Xcode Beta 4. |
|
So what's the state of the issue? |
|
The compiler from both Xcode 11 Beta and the Command Line Tools produce code which segfaults in the I provided Apple some feedback via their Beta Feedback App. I am not entirely sure that this is a compiler bug. Looks strange to me, that only the |
|
Mmmm... my version of |
|
@jedisct1 Does this version work for you? |
|
What about macOS Catalina 10.15 Beta (19A512f)? Is it the only difference in your envs? |
|
It does, but I don't have a good CPU like yours. No AVX512 here. |
|
This compiler version is completely broken; I installed it and the first project I compiled with it, that has nothing to do with libsodium, crashed the same way (unaligned stack). |
|
Was it fixed in a new version of the compiler? |
|
Unfortunately not. And nobody reported it on the Apple developer forums. |
|
Compiling without optimizations ( |
Why did you close the issue then? |
|
Unfortunately, keeping an issue opened here will not do anything, The solution is simply to use the stable version of Xcode. |
|
Ok now it sounds as a resolution |
|
With this version, dsvpn segfaults even before reaching the |
|
Here's a test case, in case someone wants to report this to Apple so that it is fixed. #include <fcntl.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
typedef struct {
char d[16];
void *e;
struct { char b[5536]; } f;
} i;
void g(void) {
struct addrinfo hints, *k;
memset(&hints, 0, sizeof hints);
getaddrinfo(NULL, NULL, &hints, &k);
}
int main(void) {
puts("Hello world");
fflush(stdout);
close(open("/dev/null", O_RDONLY));
i context;
context.e = open;
printf("%p\n", context.d);
g();
return 0;
}cc -mavx -O2 a.c && ./a.outlldb ./a.out
run
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
frame #0: 0x00007fff65e73316 libdyld.dylib`stack_not_16_byte_aligned_error
libdyld.dylib`stack_not_16_byte_aligned_error:
-> 0x7fff65e73316 <+0>: movdqa %xmm0, (%rsp)The stack pointer becomes invalid even before we reach the This doesn't happen without AVX, or with stable versions of the compiler. |
|
A workaround is to compile with |
|
It seems like adding In the release notes here, you can see:
|
|
The compiler emits invalid code. This has nothing to do with libsodium, see the test case above. |
|
See https://forums.developer.apple.com/thread/121887 This compiler version is broken, has obviously received insufficient testing, and even with additional compilation flags, I wouldn’t recommend using it for anything serious. |
|
FYI, this is still an issue with the release version of Catalina; as the above cross-refs show, it's showing up in a lot of other libraries, as well. (Hello from bcmyers/argonautica#20!) |
|
FWIW, this issue appears fixed in Xcode 11.2 and the crate builds successfully with it. Note that if you had installed the command line tools, using |
|
I can confirm that the suggestion by eliaslevy works as advertised. Thanks. |
During
make checkthepwhash_argon2iandpwhash_argon2idtests fail with a segmention fault.Tested on
0.18.0-RELEASEand fdfca24Compiler
Backtraces
pwhash_argon2i
pwhash_argon2id
The text was updated successfully, but these errors were encountered: