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

build with -O generate "Bus error: 10" #2888

Closed
patrickkh7788 opened this issue Oct 28, 2018 · 4 comments
Closed

build with -O generate "Bus error: 10" #2888

patrickkh7788 opened this issue Oct 28, 2018 · 4 comments

Comments

@patrickkh7788
Copy link

When build with -O, the code can random run into "Bus error: 10"

remove -O, all work fine.

this is the lldb report:

thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x100711e88)
frame #0: 0x0000000100711e88
-> 0x100711e88: fildll (%rax,%rax)
0x100711e8c: addl %eax, (%rax)
0x100711e8e: addb %al, (%rax)
0x100711e90: sbbb %bl, (%rdi)

LDC - the LLVM D compiler (1.12.0):
based on DMD v2.082.1 and LLVM 7.0.0
built with LDC - the LLVM D compiler (1.12.0)
Default target: x86_64-apple-darwin17.6.0
Host CPU: skylake

@kinke
Copy link
Member

kinke commented Oct 28, 2018

This is almost certainly a duplicate of your other issue, just depending on what random garbage address you get. Quoting from https://forums.developer.apple.com/thread/70950:

The difference between SIGSEGV and SIGBUS is a subtle one. In the general case there’s very little difference; they both mean that the CPU has taken a memory access exception (this is a machine exception, unrelated to language exceptions like you see in Objective-C, C++ and, if you squint, Swift), and the actual signal you get is both OS and hardware related.
However, on Apple platforms the difference is actually pretty clear. You get a SIGSEGV when you access unmapped memory and you get a SIGBUS when you access memory that’s mapped but whose protection isn’t compatible with your access.

Or wait, is that your code crashing instead of LDC itself?

@patrickkh7788
Copy link
Author

patrickkh7788 commented Oct 29, 2018

This is my code crashing from macOSX x86-64, random and not always repeat.

@joakim-noah
Copy link
Contributor

Sounds like optimization is screwing something up, if it's really not hitting at all on unoptimized builds. These sporadic issues are really hard to track down, best we can offer is that you will have to use lldb to try to get a feel for where in your code it's happening and see if you can produce a minimized testcase.

@patrickkh7788
Copy link
Author

Yes, I only see this error with -O, I will paste here if I get minimized test case.

Right now I use it without -O, the bad side is the binary tree search not near half the performance compare with -O.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants