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
dnsdist: init of ServerPolicies crashes on FreeBSD stable/14 #13766
Comments
Another thing: only |
It is an alignment issue. The crash happens in:
|
Some more info: luajit is indeed returning 8-byte aligned allocations, on this FreeBSD machine, but also on a debian test machine where I compiled dnsdist with clang++ 17.0.6. Why the FreeBSD compiler decides to use instructions that only work on 16-byte aligned data in the string copy constructor and the debian machine not, I don't know. It could be a different version of the c++lib used. |
link to other thread where the same bug is commented too https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=276786 |
In https://cgit.freebsd.org/src/commit/contrib/llvm-project/libcxx/include/string?h=stable/14&id=fe013be447cd855ccaf6094a1d06aea570450629 it shows that the string copy constructor was changed form non-inlined to inlined (search for |
Nice finding! I'm really surprised this doesn't break all over the place.. Still I guess it's better to work around this issue in dnsdist before we get complaints about it. Otto, would you be able to submit a PR with your patch (as far as I can tell |
I can do it later today. But I'm worried other cases might break as well.... |
This program reproduces the issue:
Compile with
|
Another finding:
|
So the summarize things:
The fundamental solution would be to to change the default alignment of the luajit allocator to agree to |
… lua(jit) luajit aligns only to 8 bytes by default, and some objects require 16 byte alignment. Fixes PowerDNS#13766
… lua(jit) luajit aligns only to 8 bytes by default, and some objects require 16 byte alignment. Fixes PowerDNS#13766 Note that the static assert in LuaContext.hpp is commented out in one case. This trips on some platforms, but does not seem to be harmful right now. The fundamental solution remains the have luajit agree with C++ on minimal alignment of its allocators.
I confirm that now it builds and runs fine. |
Originally reported by jostreff
The backtrace looks like this (using
lldb
):It might be related to the use of placement new. During the call of the copy ct, it looks like the string library code assumes
this
is already initialized, which it isn't. When I have the opportunity, I'll try to isolate this into a smaller test.Not using the full
ServerPolicy
object but a using a const pointer to it works around the issue, in the sense thatdnsdist
no longer crashes.But I have little idea if that affects Lua code in the wild.
Update: not using a
const
pointer (removing the two instances ofconst
in the diff) gets me modifiable standardServerPolicies
again. Though I would not know why you would want to change those.So far I did not succeed to reproduce in a smaller program.
The text was updated successfully, but these errors were encountered: