zerotier / ZeroTierOne

A Smart Ethernet Switch for Earth
https://zerotier.com
Other
14.14k stars 1.65k forks source link

zerotier-one crashes when compiled statically (ZT_STATIC) on armv7l #2208

Open kleuter opened 7 months ago

kleuter commented 7 months ago

Trying to compile zerotier-one on Raspberry Pi 2 (A 900MHz quad-core ARM Cortex-A7 CPU). Ubuntu 22.04

The binary works fine with normal build but gives segmentation fault when using ZT_STATIC build (had no such issues when compiling static build on arm64 on Rasberry Pi 4).

Used command line:

make -j`nproc` ZT_STATIC=1 
Some linking warnings ``` g++ -O3 -fstack-protector -Wall -Wno-deprecated -std=c++17 -pthread -Izeroidc/target -isystem ext -Iext/prometheus-cpp-lite-1.0/core/include -Iext-prometheus-cpp-lite-1.0/3rdparty/http-client-lite/include -Iext/prometheus-cpp-lite-1.0/simpleapi/include -DNDEBUG -DZT_USE_MINIUPNPC -DMINIUPNP_STATICLIB -DMINIUPNPC_SET_SOCKET_TIMEOUT -DMINIUPNPC_GET_SRC_ADDR -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -DOS_STRING="\"Linux\"" -DMINIUPNPC_VERSION_STRING="\"2.0\"" -DUPNP_VERSION_STRING="\"UPnP/1.1\"" -DENABLE_STRNATPMPERR -DZT_NO_TYPE_PUNNING -DZT_BUILD_PLATFORM=1 -DZT_BUILD_ARCHITECTURE=3 -DZT_SOFTWARE_UPDATE_DEFAULT="\"disable\"" -D_MT_ALLOCATOR_H -D_POOL_ALLOCATOR_H -D_EXTPTR_ALLOCATOR_H -D_DEBUG_ALLOCATOR_H -mfloat-abi=hard -march=armv6zk -marm -mfpu=vfp -fexceptions -mno-unaligned-access -mtp=cp15 -mcpu=arm1176jzf-s -fPIC -fPIE -pie -Wl,-z,relro,-z,now -static -o zerotier-one node/AES.o node/AES_aesni.o node/AES_armcrypto.o node/C25519.o node/Capability.o node/CertificateOfMembership.o node/CertificateOfOwnership.o node/Identity.o node/IncomingPacket.o node/InetAddress.o node/Membership.o node/Metrics.o node/Multicaster.o node/Network.o node/NetworkConfig.o node/Node.o node/OutboundMulticast.o node/Packet.o node/Path.o node/Peer.o node/Poly1305.o node/Revocation.o node/Salsa20.o node/SelfAwareness.o node/SHA512.o node/Switch.o node/Tag.o node/Topology.o node/Trace.o node/Utils.o node/Bond.o controller/EmbeddedNetworkController.o controller/DBMirrorSet.o controller/DB.o controller/FileDB.o controller/LFDB.o controller/PostgreSQL.o osdep/EthernetTap.o osdep/ManagedRoute.o osdep/Http.o osdep/OSUtils.o service/SoftwareUpdater.o service/OneService.o osdep/LinuxEthernetTap.o osdep/LinuxNetLink.o osdep/PortMapper.o ext/miniupnpc/connecthostport.o ext/miniupnpc/igd_desc_parse.o ext/miniupnpc/minisoap.o ext/miniupnpc/minissdpc.o ext/miniupnpc/miniupnpc.o ext/miniupnpc/miniwget.o ext/miniupnpc/minixml.o ext/miniupnpc/portlistingparse.o ext/miniupnpc/receivedata.o ext/miniupnpc/upnpcommands.o ext/miniupnpc/upnpdev.o ext/miniupnpc/upnperrors.o ext/miniupnpc/upnpreplyparse.o ext/libnatpmp/natpmp.o ext/libnatpmp/getgateway.o ext/http-parser/http_parser.o one.o /usr/bin/ld: one.o: in function `main': one.cpp:(.text.startup+0x678): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: controller/LFDB.o: in function `int httplib::detail::create_socket, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, int, int, bool, std::function, long, long, long, long, long, long, std::__cxx11::basic_string, std::allocator > const&, httplib::Error&)::{lambda(int, addrinfo&)#1}>(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, int, int, int, bool, std::function, httplib::detail::create_client_socket(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, int, int, bool, std::function, long, long, long, long, long, long, std::__cxx11::basic_string, std::allocator > const&, httplib::Error&)::{lambda(int, addrinfo&)#1})': LFDB.cpp:(.text._ZN7httplib6detail13create_socketIZNS0_20create_client_socketERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_iibSt8functionIFviEEllllllS9_RNS_5ErrorEEUliR8addrinfoE_EEiS9_S9_iiibSC_T_[_ZN7httplib6detail13create_socketIZNS0_20create_client_socketERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_iibSt8functionIFviEEllllllS9_RNS_5ErrorEEUliR8addrinfoE_EEiS9_S9_iiibSC_T_]+0x1ec): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking ```
kleuter commented 7 months ago

image

joseph-henry commented 6 months ago

I'll try to replicate but in the meantime can you rebuild with ZT_DEBUG=1 as well and then run it in lldb like such:

> sudo lldb ./zerotier-one
lldb> run

And then when it crashes:

lldb> bt

Then send us the result.

Thanks!

kleuter commented 6 months ago

Indeed the crash is connected with getpwnam (see warning in the first message)

photo_2024-02-13_13-57-42

Sorry the the shitty screenshot

kleuter commented 6 months ago

I don't know exactly how but it seems to be connected to GLibC Name Service Switch (NSS) mechanism internally:

Strangely it doesn't happen on armv8