We have application which works fine on macOS 10.13-11.0 with x64 architecture and in Rosetta2 on ARM. But the same code rebuilt for ARM64 caused to SEGV on
Code Block pthread_mutex_init.
Part of crash report:
Thread 9 Crashed:: MyService server thread
0 libsystempthread.dylib 0x000000019101476c pthreadmutexinit + 368
1 myservice 0x00000001024ea654 0x1024b8000 + 206420 // boost::mutex::mutex() (in myservice) (mutex.hpp:52)
2 myservice 0x00000001024e8ed4 0x1024b8000 + 200404 // boost::mutex::mutex() (in myservice) (mutex.hpp:51)
3 myservice 0x0000000102911290 0x1024b8000 + 4559504 // veeamrpc::CTcpThread::CTcpThread(std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > const&) (in myservice) (TcpThread.cpp:15)
4 myservice 0x00000001029113e0 0x1024b8000 + 4559840
5 myservice 0x00000001024fea64 0x1024b8000 + 289380
6 myservice 0x00000001024febf0 0x1024b8000 + 289776
7 myservice 0x00000001024e9564 0x1024b8000 + 202084
8 myservice 0x00000001024e8d3c 0x1024b8000 + 199996
9 myservice 0x00000001024f0810 boost::mfi::mf1<void, service::CLpbSvcServer, boost::sharedptr<api::CSocketIP> >::operator()(service::CLpbSvcServer*, boost::sharedptr<api::CSocketIP>) const + 144
10 myservice 0x00000001024f0738 void boost::bi::list2<boost::bi::value<service::CLpbSvcServer*>, boost::bi::value<boost::sharedptr<api::CSocketIP> > >::operator()<boost::mfi::mf1<void, service::CLpbSvcServer, boost::sharedptr<api::CSocketIP> >, boost::bi::list0>(boost::bi::type<void>, boost::mfi::mf1<void, service::CLpbSvcServer, boost::sharedptr<api::CSocketIP> >&, boost::bi::list0&, int) + 144
11 myservice 0x00000001024f069c boost::bi::bindt<void, boost::mfi::mf1<void, service::CLpbSvcServer, boost::sharedptr<api::CSocketIP> >, boost::bi::list2<boost::bi::value<service::CLpbSvcServer*>, boost::bi::value<boost::sharedptr<api::CSocketIP> > > >::operator()() + 72
12 myservice 0x00000001024f03b4 boost::detail::function::voidfunctionobjinvoker0<boost::bi::bindt<void, boost::mfi::mf1<void, service::CLpbSvcServer, boost::sharedptr<api::CSocketIP> >, boost::bi::list2<boost::bi::value<service::CLpbSvcServer*>, boost::bi::value<boost::sharedptr<api::CSocketIP> > > >, void>::invoke(boost::detail::function::functionbuffer&) + 36
13 myservice 0x0000000102737e3c boost::function0<void>::operator()() const + 116
14 myservice 0x0000000102737018 0x1024b8000 + 2617368
15 myservice 0x000000010273a64c boost::mfi::mf2<void, synch::Thread, boost::function<void ()>, std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > const&>::operator()(synch::Thread*, boost::function<void ()>, std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > const&) const + 152
16 myservice 0x000000010273a56c void boost::bi::list3<boost::bi::value<synch::Thread*>, boost::bi::value<boost::function<void ()> >, boost::bi::value<std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > > >::operator()<boost::mfi::mf2<void, synch::Thread, boost::function<void ()>, std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > const&>, boost::bi::list0>(boost::bi::type<void>, boost::mfi::mf2<void, synch::Thread, boost::function<void ()>, std::1::basicstring<char, std::1::chartraits<char>, std::_1::allocator<char> > const&>&, boost::bi::list0&, int) + 168
17 myservice 0x000000010273a4b8 boost::bi::bindt<void, boost::mfi::mf2<void, synch::Thread, boost::function<void ()>, std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > const&>, boost::bi::list3<boost::bi::value<synch::Thread*>, boost::bi::value<boost::function<void ()> >, boost::bi::value<std::1::basicstring<char, std::1::chartraits<char>, std::1::allocator<char> > > > >::operator()() + 72
18 myservice 0x00000001027395b4 0x1024b8000 + 2626996
19 libcpprest.2.10.dylib 0x00000001051de4a8 boost::(anonymous namespace)::threadproxy(void*) + 176
20 libsystempthread.dylib 0x000000019101906c pthreadstart + 320
21 libsystempthread.dylib 0x0000000191013da0 thread_start + 8
Maybe some additional code needed for ARM64 platform?
P.S. We have boost 1.70.
Code Block language c #pragma pack ( push ) #pragma pack ( 1 )
before and
Code Block language c #pragma pack ( pop )
after CTcpThread class declaration. So, problem was in legacy code with memory alignment preprocessor directives.
These directives were added in year 2011 originally for Linux, but without #ifdef ____linux____ somewhy.