Skip to content

Failing test suite with 0.4.0 release on MacOS #2421

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

Closed
cubranic opened this issue May 3, 2019 · 11 comments · Fixed by #2526
Closed

Failing test suite with 0.4.0 release on MacOS #2421

cubranic opened this issue May 3, 2019 · 11 comments · Fixed by #2526
Labels
bug Observed behavior contradicts documented or intended behavior os-macos
Milestone

Comments

@cubranic
Copy link

cubranic commented May 3, 2019

WIth Zig 0.4.0 built from source on macOS 10.14.4 (Mojave), I get the following error when running bin/zig build --build-file ../build.zig test -Dskip-release:

Assertion failed: ((uint64_t)loc % alignof(T) == 0 && "invalid pointer alignment"), function read64, file /Users/davor/projects/ziggly/zig/deps/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h, line 86.
The following command terminated unexpectedly:
/Users/davor/projects/ziggly/zig/build/bin/zig test /Users/davor/projects/ziggly/zig/test/standalone/static_c_lib/foo.zig --object /Users/davor/projects/ziggly/zig/test/standalone/static_c_lib/zig-cache/o/SUe_YiPh1_Ew6fiegQeR8ME86r6PNe-adxCtuWf8bVaQx3w_6ftZmy4uax5-vaqd/libfoo.a --cache-dir /Users/davor/projects/ziggly/zig/test/standalone/static_c_lib/zig-cache --name test -isystem /Users/davor/projects/ziggly/zig/test/standalone/static_c_lib/zig-cache/o/SUe_YiPh1_Ew6fiegQeR8ME86r6PNe-adxCtuWf8bVaQx3w_6ftZmy4uax5-vaqd -isystem /Users/davor/projects/ziggly/zig/test/standalone/static_c_lib

Is this a known failure, or a possible problem with my setup? There are 5,718 passing tests (counted by their printing "...OK").

@mikdusan
Copy link
Member

mikdusan commented May 3, 2019

I have been getting this same failure on macOS 10.11, 10.13 and 10.14 against different versions of Xcode but haven't really investigated.

@andrewrk andrewrk added the bug Observed behavior contradicts documented or intended behavior label May 3, 2019
@andrewrk andrewrk added this to the 0.5.0 milestone May 3, 2019
@andrewrk
Copy link
Member

andrewrk commented May 3, 2019

Does the problem occur with master branch?

@mikdusan
Copy link
Member

mikdusan commented May 3, 2019

Does the problem occur with master branch?

yes. In fact I cannot recall ever having success runing full test on macOS. On linux, yes, I get good result. Off hand I'm thinking why does it work with CI builds? Primary diff is CI uses gcc8 to build zig's LLVM toolchain, I'm using Xcode-clang. If memory serves custom-clang also gave me same failure.

@andrewrk
Copy link
Member

andrewrk commented May 3, 2019

Hmm. Unfortunately it works on my fully updated 10.14.4 macOS laptop as well so I cannot reproduce the issue. I need some help figuring out what's different about our systems. I build with Homebrew and the default system compiler.

@andrewrk
Copy link
Member

andrewrk commented May 3, 2019

I will note the assertion is in LLD, the linker, which is known to be problematic for the macOS target and one of the reasons for #1535.

@cubranic
Copy link
Author

cubranic commented May 3, 2019

Yes:

Assertion failed: ((uint64_t)loc % alignof(T) == 0 && "invalid pointer alignment"), function read64, file /Users/davor/projects/ziggly/zig/deps/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h, line 86.
The following command terminated unexpectedly:
/Users/davor/projects/ziggly/zig/build/bin/zig test /Users/davor/projects/ziggly/zig/test/standalone/static_c_lib/foo.zig --object /Users/davor/projects/ziggly/zig/test/standalone/static_c_lib/zig-cache/o/o5L8eEhBLQTVzmg8zEVN20-UmhYp5v753OP30PuJ2DNoJ9yIggEtSdicH4O2EYIN/libfoo.a --cache-dir /Users/davor/projects/ziggly/zig/test/standalone/static_c_lib/zig-cache --name test -isystem /Users/davor/projects/ziggly/zig/test/standalone/static_c_lib/zig-cache/o/o5L8eEhBLQTVzmg8zEVN20-UmhYp5v753OP30PuJ2DNoJ9yIggEtSdicH4O2EYIN -isystem /Users/davor/projects/ziggly/zig/test/standalone/static_c_lib

Build failed. The following command failed:
/Users/davor/projects/ziggly/zig/test/standalone/static_c_lib/zig-cache/o/gNZfNp5X8svdTkLz5e_tsmhdpqIG8PGIYsH7YPBHRb-djo-7VcgWzzatSmaieC2F/build /Users/davor/projects/ziggly/zig/build/bin/zig /Users/davor/projects/ziggly/zig/test/standalone/static_c_lib /Users/davor/projects/ziggly/zig/test/standalone/static_c_lib/zig-cache test
The following command exited with error code 1:
cd /Users/davor/projects/ziggly/zig && build/bin/zig build --build-file /Users/davor/projects/ziggly/zig/test/standalone/static_c_lib/build.zig test

Build failed. The following command failed:
/Users/davor/projects/ziggly/zig/zig-cache/o/XyKkE9WQu-rXGS9zS1-Rxpx3rC3ZOSwTSFWPWsbXSa31LnQ4upnkBLxBR6YPg2EW/build /Users/davor/projects/ziggly/zig/build/bin/zig /Users/davor/projects/ziggly/zig /Users/davor/projects/ziggly/zig/zig-cache test -Dskip-release

@mikdusan
Copy link
Member

mikdusan commented May 3, 2019

ok I've reduced it down to how Zig is built but have yet to find out why -DCMAKE_BUILD_TYPE=Release is a factor.

TEST FAILURE
cmake -G Ninja /Users/mike/project/zig/master -DCMAKE_INSTALL_PREFIX=/opt/zig -DCMAKE_PREFIX_PATH=/opt/llvm-8.0.0
TEST SUCCESS
cmake -G Ninja /Users/mike/project/zig/master -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/zig -DCMAKE_PREFIX_PATH=/opt/llvm-8.0.0

@cubranic
Copy link
Author

cubranic commented May 3, 2019

@andrewrk it sounds like our setups are very similar. Same OS version, and I also build with Homebrew. I used the exact directions from the README:

  • Homebrew llvm@8
  • cmake with -DCMAKE_PREFIX_PATH=/usr/local/Cellar/llvm/8.0.0

I'd be happy to dig in deeper to find differences between our two configurations.

@andrewrk
Copy link
Member

andrewrk commented May 3, 2019

@mikdusan I can explain that one: -DCMAKE_BUILD_TYPE=Release disables asserts. This issue is about an assertion failure. The LLD code probably ends up working fine in practice even though it tripped an assertion failure.

@mikdusan
Copy link
Member

mikdusan commented May 3, 2019

This looks to be a bug in lld. What's happening is the .a is loaded into MemoryBuffer and the managed buffer is not aligned. Then the usual pointer casting into mach_header which is offset-zero in the buffer. And the first field magic is 32-bit and lld code asserts with generic read functions this must be 4-byte aligned.

@ziglang ziglang deleted a comment from kristate May 4, 2019
@andrewrk

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior os-macos
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants