{"action":"created","issue":{"url":"https://api.github.com/repos/nanomsg/nanomsg/issues/77","labels_url":"https://api.github.com/repos/nanomsg/nanomsg/issues/77/labels{/name}","comments_url":"https://api.github.com/repos/nanomsg/nanomsg/issues/77/comments","events_url":"https://api.github.com/repos/nanomsg/nanomsg/issues/77/events","html_url":"https://github.com/nanomsg/nanomsg/issues/77","id":16448060,"number":77,"title":"stress testing my nanomsg usage...!assertion (NN_QUEUE_NOTINQUEUE & !assertion /home/mike/nanomsg/src/transports/utils/streamhdr.c:284","user":{"login":"mikeguidry","id":2878909,"avatar_url":"https://avatars.githubusercontent.com/u/2878909?v=3","gravatar_id":"","url":"https://api.github.com/users/mikeguidry","html_url":"https://github.com/mikeguidry","followers_url":"https://api.github.com/users/mikeguidry/followers","following_url":"https://api.github.com/users/mikeguidry/following{/other_user}","gists_url":"https://api.github.com/users/mikeguidry/gists{/gist_id}","starred_url":"https://api.github.com/users/mikeguidry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikeguidry/subscriptions","organizations_url":"https://api.github.com/users/mikeguidry/orgs","repos_url":"https://api.github.com/users/mikeguidry/repos","events_url":"https://api.github.com/users/mikeguidry/events{/privacy}","received_events_url":"https://api.github.com/users/mikeguidry/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":24,"created_at":"2013-07-07T20:28:05Z","updated_at":"2015-11-09T21:22:18Z","closed_at":null,"body":"Assertion failed: self->next == NN_QUEUE_NOTINQUEUE (/home/mike/nanomsg/src/utils/queue.c:78)\r\n\r\nProgram received signal SIGABRT, Aborted.\r\n[Switching to Thread 0x7ffff1e37700 (LWP 2527)]\r\n0x00007ffff707f425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64\r\n64      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.\r\n(gdb) bt\r\n#0  0x00007ffff707f425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64\r\n#1  0x00007ffff7082b8b in __GI_abort () at abort.c:91\r\n#2  0x00007ffff795d379 in nn_err_abort () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#3  0x00007ffff795e3ec in nn_queue_item_term () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#4  0x00007ffff795bf9f in nn_worker_task_term () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#5  0x00007ffff7959457 in nn_usock_term () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#6  0x00007ffff796af36 in nn_aipc_term () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#7  0x00007ffff796bceb in nn_bipc_handler () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#8  0x00007ffff795789e in nn_fsm_event_process () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#9  0x00007ffff795763b in nn_ctx_leave () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#10 0x00007ffff795c53f in nn_worker_routine () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#11 0x00007ffff795e8d4 in nn_thread_main_routine () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#12 0x00007ffff56efe9a in start_thread (arg=0x7ffff1e37700) at pthread_create.c:308\r\n#13 0x00007ffff713cccd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112\r\n#14 0x0000000000000000 in ?? ()\r\n(gdb) \r\n\r\non another thread:\r\nAssertion failed: 0 (/home/mike/nanomsg/src/transports/utils/streamhdr.c:284)\r\n\r\nProgram received signal SIGABRT, Aborted.\r\n[Switching to Thread 0x7ffff1e37700 (LWP 2533)]\r\n0x00007ffff707f425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64\r\n64      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.\r\n(gdb) bt\r\n#0  0x00007ffff707f425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64\r\n#1  0x00007ffff7082b8b in __GI_abort () at abort.c:91\r\n#2  0x00007ffff795d379 in nn_err_abort () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#3  0x00007ffff7968962 in nn_streamhdr_handler () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#4  0x00007ffff795789e in nn_fsm_event_process () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#5  0x00007ffff795763b in nn_ctx_leave () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#6  0x00007ffff795c53f in nn_worker_routine () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#7  0x00007ffff795e8d4 in nn_thread_main_routine () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#8  0x00007ffff56efe9a in start_thread (arg=0x7ffff1e37700) at pthread_create.c:308\r\n#9  0x00007ffff713cccd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112\r\n#10 0x0000000000000000 in ?? ()\r\n(gdb) \r\n\r\n\r\nanother:\r\nAssertion failed: self->next == NN_QUEUE_NOTINQUEUE (/home/mike/nanomsg/src/utils/queue.c:78)\r\n\r\nProgram received signal SIGABRT, Aborted.\r\n[Switching to Thread 0x7ffff1e37700 (LWP 2539)]\r\n0x00007ffff707f425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64\r\n64      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.\r\n(gdb) bt\r\n#0  0x00007ffff707f425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64\r\n#1  0x00007ffff7082b8b in __GI_abort () at abort.c:91\r\n#2  0x00007ffff795d379 in nn_err_abort () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#3  0x00007ffff795e3ec in nn_queue_item_term () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#4  0x00007ffff795bf9f in nn_worker_task_term () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#5  0x00007ffff7959457 in nn_usock_term () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#6  0x00007ffff796af36 in nn_aipc_term () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#7  0x00007ffff796bceb in nn_bipc_handler () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#8  0x00007ffff795789e in nn_fsm_event_process () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#9  0x00007ffff795763b in nn_ctx_leave () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#10 0x00007ffff795c53f in nn_worker_routine () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#11 0x00007ffff795e8d4 in nn_thread_main_routine () from /usr/local/lib/libnanomsg.so.0.0.0\r\n#12 0x00007ffff56efe9a in start_thread (arg=0x7ffff1e37700) at pthread_create.c:308\r\n#13 0x00007ffff713cccd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112\r\n#14 0x0000000000000000 in ?? ()\r\n(gdb) \r\n\r\n\r\n\r\n\r\ncode:\r\n\r\n\r\nint main(int argc, char *argv[]) {\r\n    void *data = NULL;\r\n    int r_len = 0;\r\n    int timeout = 1000;\r\n    unsigned char *s_data = NULL;\r\n    int s_len = 0;\r\n    int s;\r\n    int a;\r\n    int len;\r\n    int _time=time(0);\r\n    int i;\r\n    int found_command=0;\r\n    char file[1024];\r\n    char ipc[1024];\r\n    int ipc_num = 0;\r\n    \r\n    if (argc > 1) {\r\n        ipc_num = atoi(argv[1]) + 1;\r\n    } else ipc_num = 1;\r\n    \r\n    if (strstr(argv[0], \"curl\") || strstr(argv[0], \"adreplace\")) {\r\n        sprintf(file, \"/tmp/curl%d.ipc\", ipc_num);\r\n        sprintf(ipc, \"ipc:///tmp/curl%d.ipc\", ipc_num);\r\n        \r\n    } else {\r\n        sprintf(file, \"/tmp/adserver%d.ipc\", ipc_num);\r\n        sprintf(ipc, \"ipc:///tmp/adserver%d.ipc\", ipc_num);\r\n    }\r\n    \r\n    // initialize mysql\r\n    init();\r\n    //mysql_reopen();\r\n    s = nn_socket(AF_SP, NN_REP);\r\n    nn_setsockopt(s, NN_SOL_SOCKET, NN_RCVTIMEO, &timeout, sizeof(timeout));\r\n    nn_setsockopt(s, NN_SOL_SOCKET, NN_SNDTIMEO, &timeout, sizeof(timeout));\r\n    a = nn_bind(s, ipc);\r\n    chmod(file, 0777);\r\n    \r\n    printf(\"Bound to IPC: %s\\n\", ipc);\r\n    \r\n    _time = time(0);\r\n    while (1) {\r\n\r\n        s_len = 0;\r\n        s_data = NULL;\r\n        found_command=0;\r\n        \r\n        len = nn_recv(s, &data, NN_MSG, 0);\r\n        \r\n//        if (len) {\r\n        if (data && ((unsigned)len >= (unsigned)sizeof(NanoPkt))) {\r\n            // do whatever with data here... always be sure to set s_data, and s_len\r\n            NanoPkt *pkthdr = (NanoPkt *)data;\r\n            printf(\"NN recv len %d nanopkt cmd %d nanopkt len %d - %d %d %d\\n\", len, pkthdr->type, pkthdr->len, sizeof(Genreplace_Req), sizeof(Findrep_Req), sizeof(Final_Req));\r\n            for (i = 0; Commands[i].func != NULL; i++) {\r\n                if (pkthdr->type == Commands[i].type) {\r\n                    (*Commands[i].func)((unsigned char *)data, len, &s_data, &s_len);\r\n                    found_command=1;\r\n                    break;\r\n                }\r\n            }\r\n            \r\n            printf(\"FOund command: %d\\n\", found_command);\r\n            \r\n            // just in case something went wrong.. we have to return something or we will force a stall\r\n            if (s_data == NULL || !s_len) {\r\n                //printf(\"sending null\\n\");\r\n                nn_send(s, \"NULL\", 4, 0);\r\n            } else {\r\n                //printf(\"sending %d bytes of real data %p\\n\", s_len, s_data);\r\n                nn_send(s, s_data, s_len, 0);\r\n//                free(s_data);\r\n            }\r\n  //          nn_freemsg(data);\r\n            data = NULL;\r\n        }\r\n        \r\n        if ((time(0) - _time) > 10) {\r\n            _time = time(0);\r\n            removerep();\r\n        }\r\n  //      }\r\n        \r\n    }\r\n    nn_close(s);\r\n    \r\n}\r\n\r\n\r\n\r\n\r\n\r\nclient:\r\n   if ((reqptr = (Genreplace_Req *)malloc(sizeof(Genreplace_Req) + 1)) == NULL) return NULL;\r\n    memset(reqptr, 0, sizeof(Genreplace_Req));\r\n    reqptr->addr = ip;\r\n    reqptr->addr2 = addr2;\r\n    reqptr->width = width;\r\n    reqptr->height = height;\r\n//    memcpy(&reqptr->ip, straddr, 15);\r\n//    memcpy(&reqptr->iso, iso, 3);\r\n    \r\n    \r\n    pkt = (void *)nanopkt(GENREPLACE_REQ, &rep_len, reqptr, sizeof(Genreplace_Req));\r\n\r\n\r\n\r\nnanopkt:\r\nchar *nanopkt(int type, int *_len, void *extra, int extra_size) {\r\n    NanoPkt *pkthdr;\r\n    char *ret = NULL;\r\n    int msg_sock = 0;\r\n    int len = 0;\r\n    void *data = NULL;\r\n    void *out_data = NULL;\r\n    int out_size = 0;\r\n    char *ptr;\r\n    int value=1000;\r\n    int prio=1;\r\n    char ipc[1024];\r\n\r\n    \r\n    out_data = (void *)malloc(sizeof(NanoPkt) + extra_size + 1);\r\n    ptr = (char *)out_data;\r\n    pkthdr = (NanoPkt *)ptr;\r\n    ptr += sizeof(NanoPkt);\r\n    \r\n    pkthdr->type = type;\r\n    pkthdr->len = sizeof(NanoPkt) + extra_size;\r\n    \r\n    if (extra_size) {\r\n        memcpy(ptr, extra, extra_size);\r\n        ptr += extra_size;\r\n    }\r\n    \r\n    out_size = sizeof(NanoPkt) + extra_size;\r\n    \r\n    if ((msg_sock = nn_socket(AF_SP, NN_REQ)) < 0) goto end;\r\n    //nn_setsockopt(msg_sock, NN_SOL_SOCKET, NN_RCVTIMEO, &value, sizeof(value));\r\n    //nn_setsockopt(msg_sock, NN_SOL_SOCKET, NN_SNDTIMEO, &value, sizeof(value));\r\n    for (prio = 1; prio < 5; prio++) {\r\n        sprintf(ipc, \"ipc:///tmp/%s%d.ipc\", (type==ADREPLACE_REQ) ? \"curl\" : \"adserver\", \tprio);\r\n        nn_setsockopt (msg_sock, NN_SOL_SOCKET, NN_SNDPRIO, &prio, sizeof (int));\r\n        nn_connect(msg_sock, ipc);\r\n    }\r\n//    if (nn_connect(msg_sock, \"ipc:///tmp/adserver0.ipc\") < 0) goto end;\r\n//    doconnect(msg_sock,10);\r\n    if (nn_send(msg_sock, out_data, out_size, 0) < 0) goto end;\r\n    \r\n    len = nn_recv(msg_sock, &data, NN_MSG, 0);\r\n    \r\n    *_len = len;\r\n    \r\n    if (data && len) {\r\n        ret = malloc(len + 1);\r\n        if (ret == NULL) return NULL; // fatal should exit...\r\n        memcpy(ret, data, len);\r\n        nn_freemsg(data);\r\n    }\r\nend:;\r\n    if (msg_sock) nn_close(msg_sock);\r\n    return ret;\r\n}\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/nanomsg/nanomsg/issues/comments/155200051","html_url":"https://github.com/nanomsg/nanomsg/issues/77#issuecomment-155200051","issue_url":"https://api.github.com/repos/nanomsg/nanomsg/issues/77","id":155200051,"user":{"login":"gdamore","id":1295229,"avatar_url":"https://avatars.githubusercontent.com/u/1295229?v=3","gravatar_id":"","url":"https://api.github.com/users/gdamore","html_url":"https://github.com/gdamore","followers_url":"https://api.github.com/users/gdamore/followers","following_url":"https://api.github.com/users/gdamore/following{/other_user}","gists_url":"https://api.github.com/users/gdamore/gists{/gist_id}","starred_url":"https://api.github.com/users/gdamore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gdamore/subscriptions","organizations_url":"https://api.github.com/users/gdamore/orgs","repos_url":"https://api.github.com/users/gdamore/repos","events_url":"https://api.github.com/users/gdamore/events{/privacy}","received_events_url":"https://api.github.com/users/gdamore/received_events","type":"User","site_admin":false},"created_at":"2015-11-09T21:22:18Z","updated_at":"2015-11-09T21:22:18Z","body":"All the other failures I've found involve inproc.  We use inproc pretty heavily in our test framework..."}}