zeromq / libzmq

ZeroMQ core engine in C++, implements ZMTP/3.1
https://www.zeromq.org
Mozilla Public License 2.0
9.75k stars 2.36k forks source link

abort in zmq::tcp_listener_t::accept #3319

Closed hgourvest closed 5 years ago

hgourvest commented 5 years ago

last commit id: f615b8fdfc94d2129ee0223100c4e4a7d5d1b93d

It seem to be an unexpected error code that is not in this list:

    errno_assert (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR
                  || errno == ECONNABORTED || errno == EPROTO
                  || errno == ENOBUFS || errno == ENOMEM || errno == EMFILE
                  || errno == ENFILE);

unfotunately the error code is not logged. what should I do to log the error code? And what is the point to make it crash in this case?

The fist line is quite interesting and could be related:

2018-12-05 14:35:15.182 1620-1620/? I/wificond: Received external scan result notification from kernel. 2018-12-05 14:35:15.699 5811-5855/? A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 5855 (pool-2-thread-1), pid 5811 (com.testing.app) 2018-12-05 14:35:15.838 6517-6517/? A/DEBUG: 2018-12-05 14:35:15.838 6517-6517/? A/DEBUG: LineageOS Version: '15.1-20181204-NIGHTLY-oneplus2' 2018-12-05 14:35:15.839 6517-6517/? A/DEBUG: Build fingerprint: 'OnePlus/OnePlus2/OnePlus2:6.0.1/MMB29M/1447858500:user/release-keys' 2018-12-05 14:35:15.839 6517-6517/? A/DEBUG: Revision: '0' 2018-12-05 14:35:15.839 6517-6517/? A/DEBUG: ABI: 'arm64' 2018-12-05 14:35:15.839 6517-6517/? A/DEBUG: pid: 5811, tid: 5855, name: pool-2-thread-1 >>> com.testing.app <<< 2018-12-05 14:35:15.839 6517-6517/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr -------- 2018-12-05 14:35:15.842 6517-6517/? A/DEBUG: x0 0000000000000000 x1 00000000000016df x2 0000000000000006 x3 0000000000000008 2018-12-05 14:35:15.842 6517-6517/? A/DEBUG: x4 0000000000000029 x5 0000000000000029 x6 0000000000000029 x7 000000000000000a 2018-12-05 14:35:15.843 6517-6517/? A/DEBUG: x8 0000000000000083 x9 0000000010000000 x10 0000006feab50280 x11 0000000000000001 2018-12-05 14:35:15.843 6517-6517/? A/DEBUG: x12 0000007085ac04c0 x13 00000000fffffffc x14 0000000000000000 x15 0000000000000003 2018-12-05 14:35:15.843 6517-6517/? A/DEBUG: x16 000000558c823fa8 x17 0000007085a7b63c x18 0000007085ae9000 x19 00000000000016b3 2018-12-05 14:35:15.843 6517-6517/? A/DEBUG: x20 00000000000016df x21 0000000000000083 x22 0000006feab51588 x23 0000006feab502e8 2018-12-05 14:35:15.843 6517-6517/? A/DEBUG: x24 0000006feab51588 x25 0000006feab50418 x26 0000007002909220 x27 0000000000000058 2018-12-05 14:35:15.843 6517-6517/? A/DEBUG: x28 0000000000000003 x29 0000006feab502c0 x30 0000007085a2f72c 2018-12-05 14:35:15.843 6517-6517/? A/DEBUG: sp 0000006feab50280 pc 0000007085a2f754 pstate 0000000060000000 2018-12-05 14:35:15.861 6517-6517/? A/DEBUG: backtrace: 2018-12-05 14:35:15.861 6517-6517/? A/DEBUG: #00 pc 000000000001d754 /system/lib64/libc.so (abort+120) 2018-12-05 14:35:15.861 6517-6517/? A/DEBUG: #01 pc 00000000000b073c /data/app/com.testing.app-p-Fr2JBBHTezqB2hPV72yg==/lib/arm64/libzeromq.so (zmq::zmq_abort(char const)+8) 2018-12-05 14:35:15.861 6517-6517/? A/DEBUG: #02 pc 00000000000e20f4 /data/app/com.testing.app-p-Fr2JBBHTezqB2hPV72yg==/lib/arm64/libzeromq.so (zmq::tcp_listener_t::accept()+416) 2018-12-05 14:35:15.861 6517-6517/? A/DEBUG: #03 pc 00000000000e1d24 /data/app/com.testing.app-p-Fr2JBBHTezqB2hPV72yg==/lib/arm64/libzeromq.so (zmq::tcp_listener_t::in_event()+28) 2018-12-05 14:35:15.861 6517-6517/? A/DEBUG: #04 pc 00000000000b0440 /data/app/com.testing.app-p-Fr2JBBHTezqB2hPV72yg==/lib/arm64/libzeromq.so (zmq::epoll_t::loop()+200) 2018-12-05 14:35:15.861 6517-6517/? A/DEBUG: #05 pc 00000000000e25bc /data/app/com.testing.app-p-Fr2JBBHTezqB2hPV72yg==/lib/arm64/libzeromq.so 2018-12-05 14:35:15.861 6517-6517/? A/DEBUG: #06 pc 0000000000068e90 /system/lib64/libc.so (__pthread_start(void)+36) 2018-12-05 14:35:15.861 6517-6517/? A/DEBUG: #07 pc 000000000001ebe4 /system/lib64/libc.so (__start_thread+68)

hgourvest commented 5 years ago

I compile for Android Api level 16, and I need to undef these compiler options:

define ZMQ_HAVE_ANDROID 1

undef ZMQ_HAVE_PTHREAD_SET_AFFINITY

undef ZMQ_HAVE_TIPC

undef ZMQ_HAVE_GETRANDOM

undef ZMQ_HAVE_SOCK_CLOEXEC

undef ZMQ_IOTHREAD_POLLER_USE_EPOLL_CLOEXEC

hgourvest commented 5 years ago

I got it: EINVAL = 22

hgourvest commented 5 years ago

The problem occur when I desactivate and reactivate the wifi on my phone, if I add EINVAL to the list it not crash anymore, but I don't know it is the right thing to do. Any advice?

hgourvest commented 5 years ago

BTW this is the Android permissions I use:

hgourvest commented 5 years ago

android.permission.INTERNET android.permission.ACCESS_NETWORK_STATE android.permission.ACCESS_WIFI_STATE

hgourvest commented 5 years ago

fixed in his merge https://github.com/zeromq/libzmq/pull/3326