asio icon indicating copy to clipboard operation
asio copied to clipboard

Mismatched-alloc

Open keef-cognitiv opened this issue 2 years ago • 1 comments

Someone had already opened this and the issue was ultimately that they had binaries compiled with C++17 and non-C++17 interacting. I was compiling everything against C++17. The issue is in:

https://github.com/chriskohlhoff/asio/blob/master/asio/include/asio/detail/config.hpp#L663

There's nothing there to include the standard gcc bits so that the _GLIBCXX_HAVE_ALIGNED_ALLOC value will be defined properly. It's ultimately depending on the user (me) having included some other thing from libstdc++ to pull that in before including anything in asio... since the config.hpp is ultimately the first include in most asio header files. After fighting with include orders to try to force it to work for some time, I just gave up and patched the above to read:

#   elif defined(__GNUC__)
#    include <bits/c++config.h>
#    if defined(_GLIBCXX_HAVE_ALIGNED_ALLOC)
#     define ASIO_HAS_STD_ALIGNED_ALLOC 1

And all of the memory errors are resolved. But this was probably a crappy way to fix it.

The issue in my case was that the io_context.run() was called from some TU that had transitively included the gcc macros into asio. But async_wait was called somewhere where it wasn't. But the latter was included via a patchwork headers so it ended up being a painful hunt to try to force that include into every file before asio bits are included that I just gave up on.

keef-cognitiv avatar Jul 09 '22 07:07 keef-cognitiv

I think this commit 6d51490576ef219f3bc6dda3baecc3a9efe49dd5 fixed your problem.

liubing avatar Aug 17 '22 09:08 liubing