-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
SIGBUS due to unaligned access #6015
Comments
I don't see where the code on the stack is associated with unaligned access. |
Some more info. I reproduced this issue in
And this is disassembly mapped to source lines:
I also found out that disabling optimization makes the bug go away. Could it be a miscompilation on the Clang side? |
Thinking about it, the |
Can you try replacing line 936 of src/smt/smt_setup.cpp with: m_context.register_plugin(new smt::theory_seq(m_context)); Just wanted to test a theory. |
This changes the error message to:
This usually means memory corruption. Any hints what to do with this? |
(updated useless comment) |
What libraries exactly? |
Can you try without jemalloc? It may not be aligning the allocation sufficiently. |
I doubt it, it is a default malloc in FreeBSD libc. I'll try Clang sanitizers, then. |
The backtrace I get with debug build and 936 line patched:
|
That trace doesn't help, sorry. |
Closing this for now. Please reopen once you've more information. Thank you! |
AddressSanitizer didn't help as it hides the problem just as building in the debugging mode. However, applying the following hack fixed the problem for me:
Could it be that |
Oh dear.. It makes sense: your crash is in |
Why do you need to store the memory buffer's length in the first place? |
To keep track of memory consumption. That's very important to avoid explosions. |
in reality it is mostly aspirational: one can also query the heap for information and when using std::string and other std:: with the default memory allocator it isn't tracked. We tried using mimalloc for mpz specifically and the savings were not clearly measurable, but with mimalloc could also have the memory module be a throughfare to it. Well-supported allocators should handle alignment compatibility properly. |
Yep, the following change worked for me too:
The Interestingly, adding |
Would this be a workaround? |
Yep, this isn't a proper fix, but the package is broken at the moment, so I need something until you figure out a proper solution.
Can't we just compute it at runtime with |
I don't know what the runtime utility would be (if-defed if it isn't cross-platform), but it is very fine too if there is something that can be used. The hard fix seems to just get rid of this layer and use mimalloc that is better engineered and appears to have utility to query heap allocated memory for allocation size. |
alright, we need something like std::alignof to either be queried once or passed by the alloc macro. https://en.cppreference.com/w/cpp/language/alignof; or just use 16 for everything; or use mimalloc. |
Any movement on this? |
If you want to make a move, the better option appears to be to port memory_manager to use instead mimalloc. |
I don't know if your BSD supports |
ah, good. So maybe we can have the glibc version and then patch to learn about freebsd as well? |
fixed, thank you! |
Ping, is there any workarounds without having to patch Z3 source? |
Starting a new thread with new info.... |
I'm running Z3 4.8.16 compiled with Clang 13 on FreeBSD 14. Z3 is being used as a library by the KLEE project. A lot of KLEE testcases fail for me due to SIGBUS inside libz3.so. Here are my findings:
The address being access is not aligned to 64:
Let me know if I can provide more info to debug this.
The text was updated successfully, but these errors were encountered: