{"action":"created","issue":{"url":"https://api.github.com/repos/nanomsg/nng/issues/346","repository_url":"https://api.github.com/repos/nanomsg/nng","labels_url":"https://api.github.com/repos/nanomsg/nng/issues/346/labels{/name}","comments_url":"https://api.github.com/repos/nanomsg/nng/issues/346/comments","events_url":"https://api.github.com/repos/nanomsg/nng/issues/346/events","html_url":"https://github.com/nanomsg/nng/issues/346","id":314305078,"number":346,"title":"nng_recv() sometimes acts on null `msg` pointer","user":{"login":"blattersturm","id":24576130,"avatar_url":"https://avatars1.githubusercontent.com/u/24576130?v=4","gravatar_id":"","url":"https://api.github.com/users/blattersturm","html_url":"https://github.com/blattersturm","followers_url":"https://api.github.com/users/blattersturm/followers","following_url":"https://api.github.com/users/blattersturm/following{/other_user}","gists_url":"https://api.github.com/users/blattersturm/gists{/gist_id}","starred_url":"https://api.github.com/users/blattersturm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blattersturm/subscriptions","organizations_url":"https://api.github.com/users/blattersturm/orgs","repos_url":"https://api.github.com/users/blattersturm/repos","events_url":"https://api.github.com/users/blattersturm/events{/privacy}","received_events_url":"https://api.github.com/users/blattersturm/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-04-14T06:48:29Z","updated_at":"2018-04-14T19:52:03Z","closed_at":null,"author_association":"NONE","body":"## NNG & Platform details.\r\n\r\nNNG commit 6401d100e8b616c65014ae7fd62ac9a575466bef\r\nWindows 10 (RS3, 10.0.16299)\r\nusing from C++\r\n\r\n## Expected Behavior\r\nNo segfault in nng_recv on calling nng_msg_len.\r\n\r\n## Actual Behavior\r\nSegfault, nng_recvmsg rv = 0, msg = NULL.\r\n\r\n## Steps to Reproduce\r\nHaven't found a minimal repro yet, however some details on our usage:\r\n\r\n- 2 threads, let's name them 'main' and 'net'\r\n- each thread owns a client req (our understanding is this allows resending?) inproc:// socket to the thread's rep socket (`inproc://net` and `inproc://main`)\r\n- 4-byte messages get sent to signal wakeup, no other data is sent at this time\r\n- recv call:\r\n\r\n```cpp\r\n\t\t\t\t\twhile (nng_recv(netSocket, &msgBuffer, &msgLen, NNG_FLAG_NONBLOCK | NNG_FLAG_ALLOC) == 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tnng_free(msgBuffer, msgLen);\r\n\r\n\t\t\t\t\t\tint ok = 0;\r\n\t\t\t\t\t\tnng_send(netSocket, &ok, 4, NNG_FLAG_NONBLOCK);\r\n\r\n\t\t\t\t\t\tm_netThreadCallbacks.Run();\r\n\t\t\t\t\t}\r\n```\r\n\r\n- send call:\r\n```cpp\r\n\t\tnng_send(sockets[i], &idxList[0], idxList.size() * sizeof(int), NNG_FLAG_NONBLOCK);\r\n```\r\n\r\nWe're also having some other issues with `aio` lifetime on both Linux and Windows - possibly some kind of use-after-free or double frees, but no actual coredump at hand for this. 😕 "},"comment":{"url":"https://api.github.com/repos/nanomsg/nng/issues/comments/381355750","html_url":"https://github.com/nanomsg/nng/issues/346#issuecomment-381355750","issue_url":"https://api.github.com/repos/nanomsg/nng/issues/346","id":381355750,"user":{"login":"gdamore","id":1295229,"avatar_url":"https://avatars2.githubusercontent.com/u/1295229?v=4","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":"2018-04-14T19:52:02Z","updated_at":"2018-04-14T19:52:02Z","author_association":"CONTRIBUTOR","body":"Thanks, this is helpful.  I'll be in touch soon... it might take a day or two."}}
{"actor":{"display_login":"gdamore"}}