{"action":"created","issue":{"url":"https://api.github.com/repos/zeromq/czmq/issues/1523","repository_url":"https://api.github.com/repos/zeromq/czmq","labels_url":"https://api.github.com/repos/zeromq/czmq/issues/1523/labels{/name}","comments_url":"https://api.github.com/repos/zeromq/czmq/issues/1523/comments","events_url":"https://api.github.com/repos/zeromq/czmq/issues/1523/events","html_url":"https://github.com/zeromq/czmq/issues/1523","id":181211994,"number":1523,"title":"zactor_new on MIPS architecture causes a SIGABRT","user":{"login":"matttbe","id":768677,"avatar_url":"https://avatars.githubusercontent.com/u/768677?v=3","gravatar_id":"","url":"https://api.github.com/users/matttbe","html_url":"https://github.com/matttbe","followers_url":"https://api.github.com/users/matttbe/followers","following_url":"https://api.github.com/users/matttbe/following{/other_user}","gists_url":"https://api.github.com/users/matttbe/gists{/gist_id}","starred_url":"https://api.github.com/users/matttbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matttbe/subscriptions","organizations_url":"https://api.github.com/users/matttbe/orgs","repos_url":"https://api.github.com/users/matttbe/repos","events_url":"https://api.github.com/users/matttbe/events{/privacy}","received_events_url":"https://api.github.com/users/matttbe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2016-10-05T17:05:44Z","updated_at":"2016-10-06T08:58:53Z","closed_at":null,"body":"Hello,\r\n\r\nFirst I would like to thank you again for your work of developing and maintaining this ZMQ project! But most importantly, I would also say that I am sorry for your loss. I am sure Pieter is glad to see that his projects are continuing to be developed and maintained like I wanted :-)\r\n\r\nAbout my bug, I am playing a bit with CZMQ on a MIPS architecture. I only wanted to be notified when my program was no longer connected to a client using a `zactor`. Unfortunately, a `SIGABRT` signal is sent by CZMQ internal code. Here is my very short code:\r\n\r\n``` c\r\n#include <stdio.h>\r\n\r\n#include <czmq.h>\r\n\r\nint\r\nmain (int argc, char *const argv[])\r\n{\r\n\tzsock_t *client = zsock_new (ZMQ_DEALER);\r\n\tassert (client);\r\n\tprintf (\"zsock_new\\n\");\r\n\tzactor_t *clientmon = zactor_new (zmonitor, client);\r\n\tprintf (\"zactor_new\\n\");\r\n\tzactor_destroy (&clientmon);\r\n\tzsock_destroy (&client);\r\n\treturn 0;\r\n}\r\n```\r\n\r\nWhen I execute it, I see:\r\n``` bash\r\n$ LD_LIBRARY_PATH=/tmp /tmp/notify\r\nzsock_new\r\n/tmp/notify: src/zframe.c: 123: zframe_recv: Assertion `source' failed.\r\n```\r\n\r\nUsing GDB (via GDBServer) I can get more details:\r\n```\r\n#0  0x77d02ea4 in kill () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libc.so.0\r\nNo symbol table info available.\r\n#1  0x77d479c4 in abort () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libc.so.0\r\nNo symbol table info available.\r\n#2  0x77d072e8 in __assert () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libc.so.0\r\nNo symbol table info available.\r\n#3  0x0043a22c in zframe_recv (source=0x0) at src/zframe.c:123\r\n        __PRETTY_FUNCTION__ = \"zframe_recv\"\r\n        handle = 0x0\r\n        self = 0x0\r\n#4  0x004290fc in s_self_handle_sink (self=0xa242f8) at src/zmonitor.c:202\r\n        frame = 0x0\r\n        event = 1\r\n        value = 0\r\n        address = 0x0\r\n        name = 0x4f6d00 <Address 0x4f6d00 out of bounds>\r\n#5  0x0042955c in zmonitor (pipe=0xa23298, sock=0xa1f150) at src/zmonitor.c:295\r\n        which = 0x0\r\n        self = 0xa242f8\r\n        __PRETTY_FUNCTION__ = \"zmonitor\"\r\n#6  0x0040d0a0 in s_thread_shim (args=0xa23288) at src/zactor.c:67\r\n        __PRETTY_FUNCTION__ = \"s_thread_shim\"\r\n        shim = 0xa23288\r\n#7  0x77d782c4 in pthread_start_thread () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libpthread.so.0\r\nNo symbol table info available.\r\n#8  0x77d01028 in __thread_start () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libc.so.0\r\nNo symbol table info available.\r\nBacktrace stopped: frame did not save the PC\r\n```\r\n\r\nWith the source code of CZMQ:\r\n\r\n```\r\n(gdb) f 3\r\n#3  0x0043a22c in zframe_recv (source=0x0) at src/zframe.c:123\r\n123\t    assert (source);\r\n(gdb) l\r\n118\t//  zpoller or zloop.\r\n119\t\r\n120\tzframe_t *\r\n121\tzframe_recv (void *source)\r\n122\t{\r\n123\t    assert (source);\r\n124\t    void *handle = zsock_resolve (source);\r\n125\t    zframe_t *self = zframe_new (NULL, 0);\r\n126\t    assert (self);\r\n127\t\r\n(gdb) f 4\r\n#4  0x004290fc in s_self_handle_sink (self=0xa242f8) at src/zmonitor.c:202\r\n202\t    zframe_t *frame = zframe_recv (self->sink);\r\n(gdb) l\r\n197\ts_self_handle_sink (self_t *self)\r\n198\t{\r\n199\t#if defined (ZMQ_EVENT_ALL)\r\n200\t#if (ZMQ_VERSION_MAJOR == 4)\r\n201\t    //  First frame is event number and value\r\n202\t    zframe_t *frame = zframe_recv (self->sink);\r\n203\t    int event = *(uint16_t *) (zframe_data (frame));\r\n204\t    int value = *(uint32_t *) (zframe_data (frame) + 2);\r\n205\t    //  Address is in second message frame\r\n206\t    char *address = zstr_recv (self->sink);\r\n(gdb) f 5\r\n#5  0x0042955c in zmonitor (pipe=0xa23298, sock=0xa1f150) at src/zmonitor.c:295\r\n295\t            s_self_handle_sink (self);\r\n(gdb) l\r\n290\t        zsock_t *which = (zsock_t *) zpoller_wait (self->poller, -1);\r\n291\t        if (which == self->pipe)\r\n292\t            s_self_handle_pipe (self);\r\n293\t        else\r\n294\t        if (which == self->sink)\r\n295\t            s_self_handle_sink (self);\r\n296\t        else\r\n297\t        if (zpoller_terminated (self->poller))\r\n298\t            break;          //  Interrupted\r\n299\t    }\r\n(gdb) p *self\r\n$2 = {pipe = 0xa23298, poller = 0xa25b70, monitored = 0xa23338, sink = 0x0, events = 0, terminated = false, verbose = false}\r\n(gdb) p which\r\n$3 = (zsock_t *) 0x0\r\n(gdb) f 6\r\n#6  0x0040d0a0 in s_thread_shim (args=0xa23288) at src/zactor.c:67\r\n67\t    shim->handler (shim->pipe, shim->args);\r\n(gdb) l\r\n62\tstatic void *\r\n63\ts_thread_shim (void *args)\r\n64\t{\r\n65\t    assert (args);\r\n66\t    shim_t *shim = (shim_t *) args;\r\n67\t    shim->handler (shim->pipe, shim->args);\r\n68\t    //  Do not block, if the other end of the pipe is already deleted\r\n69\t    zsock_set_sndtimeo (shim->pipe, 0);\r\n70\t    zsock_signal (shim->pipe, 0);\r\n71\t    zsock_destroy (&shim->pipe);\r\n```\r\n\r\nOr a backtrace for all thread:\r\n```\r\nThread 5 (Thread 15169):\r\n#0  0x77d01900 in epoll_wait () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libc.so.0\r\nNo symbol table info available.\r\n#1  0x77d7dad8 in epoll_wait () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libpthread.so.0\r\nNo symbol table info available.\r\n#2  0x0045b98c in zmq::epoll_t::loop (this=0xa232b8) at src/epoll.cpp:159\r\n        timeout = <value optimized out>\r\n        n = <value optimized out>\r\n        ev_buf = {{events = 0, data = {ptr = 0x0, fd = 0, u32 = 0, u64 = 0}} <repeats 254 times>, {events = 2010596560, data = {ptr = 0x1, fd = 1, u32 = 1, u64 = 6305593944}}, {events = 0, data = {ptr = 0x0, fd = 0, u32 = 0, \r\n              u64 = 0}}}\r\n#3  0x0047ee50 in thread_routine (arg_=0xa23320) at src/thread.cpp:100\r\n        signal_set = {__val = {4294967295, 4294967295, 4294967295, 4294967295}}\r\n        rc = <value optimized out>\r\n        self = 0xa23320\r\n#4  0x77d782c4 in pthread_start_thread () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libpthread.so.0\r\nNo symbol table info available.\r\n#5  0x77d01028 in __thread_start () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libc.so.0\r\nNo symbol table info available.\r\nBacktrace stopped: frame did not save the PC\r\n\r\nThread 4 (Thread 15168):\r\n#0  0x77d01900 in epoll_wait () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libc.so.0\r\nNo symbol table info available.\r\n#1  0x77d7dad8 in epoll_wait () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libpthread.so.0\r\nNo symbol table info available.\r\n#2  0x0045b98c in zmq::epoll_t::loop (this=0xa20cf8) at src/epoll.cpp:159\r\n        timeout = <value optimized out>\r\n        n = <value optimized out>\r\n        ev_buf = {{events = 0, data = {ptr = 0x0, fd = 0, u32 = 0, u64 = 0}} <repeats 246 times>, {events = 0, data = {ptr = 0x0, fd = 0, u32 = 0, u64 = 0}}, {events = 0, data = {ptr = 0x77ef9010, fd = 2012188688, \r\n              u32 = 2012188688, u64 = 8642284608341147648}}, {events = 2010594116, data = {ptr = 0x0, fd = 0, u32 = 0, u64 = 2012069888}}, {events = 4026531840, data = {ptr = 0xa20d60, fd = 10620256, u32 = 10620256, \r\n              u64 = 45613652195148537}}, {events = 5172496, data = {ptr = 0x265, fd = 613, u32 = 613, u64 = 2632819182775}}, {events = 9, data = {ptr = 0x7f1ffd80, fd = 2132802944, u32 = 2132802944, u64 = 9160318895304598908}}, {\r\n            events = 0, data = {ptr = 0x0, fd = 0, u32 = 0, u64 = 0}}, {events = 0, data = {ptr = 0x77ef9010, fd = 2012188688, u32 = 2012188688, u64 = 8642284608341147648}}, {events = 2010596560, data = {ptr = 0x1, fd = 1, \r\n              u32 = 1, u64 = 6305593944}}, {events = 2130710528, data = {ptr = 0x0, fd = 0, u32 = 0, u64 = 2012088952}}}\r\n#3  0x0047ee50 in thread_routine (arg_=0xa20d60) at src/thread.cpp:100\r\n        signal_set = {__val = {4294967295, 4294967295, 4294967295, 4294967295}}\r\n        rc = <value optimized out>\r\n        self = 0xa20d60\r\n#4  0x77d782c4 in pthread_start_thread () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libpthread.so.0\r\nNo symbol table info available.\r\n#5  0x77d01028 in __thread_start () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libc.so.0\r\nNo symbol table info available.\r\nBacktrace stopped: frame did not save the PC\r\n\r\nThread 3 (Thread 15167):\r\n#0  0x77d03cd4 in poll () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libc.so.0\r\nNo symbol table info available.\r\n#1  0x77d7894c in __pthread_manager () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libpthread.so.0\r\nNo symbol table info available.\r\n#2  0x77d01028 in __thread_start () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libc.so.0\r\nNo symbol table info available.\r\nBacktrace stopped: frame did not save the PC\r\n\r\nThread 2 (Thread 15170):\r\n#0  0x77d02ea4 in kill () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libc.so.0\r\nNo symbol table info available.\r\n#1  0x77d479c4 in abort () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libc.so.0\r\nNo symbol table info available.\r\n#2  0x77d072e8 in __assert () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libc.so.0\r\nNo symbol table info available.\r\n#3  0x0043a22c in zframe_recv (source=0x0) at src/zframe.c:123\r\n        __PRETTY_FUNCTION__ = \"zframe_recv\"\r\n        handle = 0x0\r\n        self = 0x0\r\n#4  0x004290fc in s_self_handle_sink (self=0xa242f8) at src/zmonitor.c:202\r\n        frame = 0x0\r\n        event = 1\r\n        value = 0\r\n        address = 0x0\r\n        name = 0x4f6d00 <Address 0x4f6d00 out of bounds>\r\n#5  0x0042955c in zmonitor (pipe=0xa23298, sock=0xa1f150) at src/zmonitor.c:295\r\n        which = 0x0\r\n        self = 0xa242f8\r\n        __PRETTY_FUNCTION__ = \"zmonitor\"\r\n#6  0x0040d0a0 in s_thread_shim (args=0xa23288) at src/zactor.c:67\r\n        __PRETTY_FUNCTION__ = \"s_thread_shim\"\r\n        shim = 0xa23288\r\n#7  0x77d782c4 in pthread_start_thread () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libpthread.so.0\r\nNo symbol table info available.\r\n#8  0x77d01028 in __thread_start () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libc.so.0\r\nNo symbol table info available.\r\nBacktrace stopped: frame did not save the PC\r\n\r\nThread 1 (Thread 13340):\r\n#0  0x77d03cd4 in poll () from /opt/toolchains/crosstools-mips-gcc-4.6-linux-3.4-uclibc-0.9.32-binutils-2.21/usr/mips-unknown-linux-uclibc/sysroot/lib/libc.so.0\r\nNo symbol table info available.\r\n#1  0x0046ea98 in zmq::signaler_t::wait (this=0xa24104, timeout_=<value optimized out>) at src/signaler.cpp:222\r\n        pfd = {fd = 19, events = 1, revents = 0}\r\n        rc = <value optimized out>\r\n#2  0x0045cba0 in zmq::mailbox_t::recv (this=0xa24098, cmd_=0x7f9f3e80, timeout_=<value optimized out>) at src/mailbox.cpp:81\r\n        rc = <value optimized out>\r\n#3  0x004709c0 in zmq::socket_base_t::process_commands (this=0xa257c8, timeout_=<value optimized out>, throttle_=false) at src/socket_base.cpp:1420\r\n        rc = <value optimized out>\r\n        cmd = {destination = 0x4d0000, type = 4630636, args = {stop = {<No data fields>}, plug = {<No data fields>}, own = {object = 0x61}, attach = {engine = 0x61}, bind = {pipe = 0x61}, activate_read = {<No data fields>}, \r\n            activate_write = {msgs_read = 418622236672}, hiccup = {pipe = 0x61}, pipe_term = {<No data fields>}, pipe_term_ack = {<No data fields>}, term_req = {object = 0x61}, term = {linger = 97}, \r\n            term_ack = {<No data fields>}, reap = {socket = 0x61}, reaped = {<No data fields>}, done = {<No data fields>}}}\r\n#4  0x00471f40 in zmq::socket_base_t::recv (this=0xa257c8, msg_=0xa262fc, flags_=<value optimized out>) at src/socket_base.cpp:1320\r\n        rc = -1\r\n        timeout = -1\r\n        end = 0\r\n        block = <value optimized out>\r\n#5  0x00449434 in s_recvmsg (s_=<value optimized out>, msg_=0xa262fc, flags_=<value optimized out>) at src/zmq.cpp:488\r\n        rc = <value optimized out>\r\n        sz = <value optimized out>\r\n#6  0x0043a2bc in zframe_recv (source=0xa24078) at src/zframe.c:128\r\n        __PRETTY_FUNCTION__ = \"zframe_recv\"\r\n        handle = 0xa257c8\r\n        self = 0xa262f8\r\n#7  0x0040df68 in zmsg_recv (source=0xa24078) at src/zmsg.c:92\r\n        frame = 0x7f9f4f29\r\n        __PRETTY_FUNCTION__ = \"zmsg_recv\"\r\n        self = 0xa26048\r\n#8  0x00422068 in zsock_wait (self=0xa24078) at src/zsock.c:1665\r\n        msg = 0x40cdd0\r\n        rc = 1\r\n        __PRETTY_FUNCTION__ = \"zsock_wait\"\r\n#9  0x0040d318 in zactor_new (actor=0x429448 <zmonitor>, args=0xa1f150) at src/zactor.c:140\r\n        self = 0xa20ce0\r\n        __PRETTY_FUNCTION__ = \"zactor_new\"\r\n        shim = 0xa23288\r\n        thread = 3076\r\n#10 0x0040ce8c in main (argc=1, argv=0x7f9f4124) at notify.c:11\r\n        client = 0xa1f150\r\n        __PRETTY_FUNCTION__ = \"main\"\r\n        clientmon = 0x40cdd0\r\n```\r\n\r\nWe can see on the frame 5 of the thread 2 (the one which sends the `SIGABRT`) that `which == self->sink` because they are both `NULL`. I guess it is not normal.\r\n\r\nAny idea of what I could do to help debugging this?\r\n\r\nPS: I am using recent version of libzmq (9561cc8) and czmq (704256b) but compiled with gcc-4.6 with uclibc, Linux 3.4 kernel."},"comment":{"url":"https://api.github.com/repos/zeromq/czmq/issues/comments/251905376","html_url":"https://github.com/zeromq/czmq/issues/1523#issuecomment-251905376","issue_url":"https://api.github.com/repos/zeromq/czmq/issues/1523","id":251905376,"user":{"login":"matttbe","id":768677,"avatar_url":"https://avatars.githubusercontent.com/u/768677?v=3","gravatar_id":"","url":"https://api.github.com/users/matttbe","html_url":"https://github.com/matttbe","followers_url":"https://api.github.com/users/matttbe/followers","following_url":"https://api.github.com/users/matttbe/following{/other_user}","gists_url":"https://api.github.com/users/matttbe/gists{/gist_id}","starred_url":"https://api.github.com/users/matttbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matttbe/subscriptions","organizations_url":"https://api.github.com/users/matttbe/orgs","repos_url":"https://api.github.com/users/matttbe/repos","events_url":"https://api.github.com/users/matttbe/events{/privacy}","received_events_url":"https://api.github.com/users/matttbe/received_events","type":"User","site_admin":false},"created_at":"2016-10-06T08:58:53Z","updated_at":"2016-10-06T08:58:53Z","body":"Thanks!\r\n\r\nAccording to `src/platform.hpp` file, EPoll is used (`#define ZMQ_USE_EPOLL 1`, all the other poll systems are not defined). I have already used EPoll before, I think it is working fine on this platform but I was maybe not using it with the same options, etc.\r\n\r\nAlso, I found something strange on this platform when using `ps | grep /notify` (`ps` from busybox) after adding a breakpoint in `zmonitor`:\r\n\r\n```\r\n11111 admin     1316 S    gdbserver :5341 ./notify\r\n11114 admin     3128 t    ./notify\r\n11205 admin     3128 t    ./notify\r\n11206 admin     3128 t    ./notify\r\n11207 admin     3128 t    ./notify\r\n11208 admin     3128 t    ./notify\r\n27378 admin     3088 S    grep /notify\r\n```\r\n\r\nIt seems a kind of process is used instead of a thread. But `gdb` tells me that I have different threads:\r\n```\r\n[New Thread 11205]\r\n[New Thread 11206]\r\n[New Thread 11207]\r\n[New Thread 11208]\r\nThread 1 (Thread 11114):\r\n```\r\n\r\nI have maybe a bad kernel config."}}
{"actor":{"display_login":"matttbe"}}