{"action":"created","issue":{"url":"https://api.github.com/repos/aerospike/aerospike-client-c/issues/49","repository_url":"https://api.github.com/repos/aerospike/aerospike-client-c","labels_url":"https://api.github.com/repos/aerospike/aerospike-client-c/issues/49/labels{/name}","comments_url":"https://api.github.com/repos/aerospike/aerospike-client-c/issues/49/comments","events_url":"https://api.github.com/repos/aerospike/aerospike-client-c/issues/49/events","html_url":"https://github.com/aerospike/aerospike-client-c/issues/49","id":190736663,"number":49,"title":"Segment fault in as_event_loop_get","user":{"login":"prasad-joshi","id":423167,"avatar_url":"https://avatars.githubusercontent.com/u/423167?v=3","gravatar_id":"","url":"https://api.github.com/users/prasad-joshi","html_url":"https://github.com/prasad-joshi","followers_url":"https://api.github.com/users/prasad-joshi/followers","following_url":"https://api.github.com/users/prasad-joshi/following{/other_user}","gists_url":"https://api.github.com/users/prasad-joshi/gists{/gist_id}","starred_url":"https://api.github.com/users/prasad-joshi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prasad-joshi/subscriptions","organizations_url":"https://api.github.com/users/prasad-joshi/orgs","repos_url":"https://api.github.com/users/prasad-joshi/repos","events_url":"https://api.github.com/users/prasad-joshi/events{/privacy}","received_events_url":"https://api.github.com/users/prasad-joshi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-21T14:46:11Z","updated_at":"2016-11-22T06:48:52Z","closed_at":null,"body":"Hello All,\r\n\r\nI am working on Aerospike Async C APIs. For async event handling, I am creating a single thread using \r\n`as_event_loop_get`. The complete async code is available in `async_client.txt` file attached herewith.\r\n\r\nWhenever I run the program, I keep on getting segment faults.\r\n[async_client.txt](https://github.com/aerospike/aerospike-client-c/files/603840/async_client.txt)\r\n\r\nThe async client program creates a pipe between parent and child process. The child process keeps on adding key+values on a pipe. Parent reads from pipe and inserts key into Aerospike KV store.\r\n\r\nAs I was continuously running into segment faults, tried debugging the code and realized the function `as_event_loop_get` tries to access invalid pointer. The problem seems to be with the next pointer used in circular link list.\r\n\r\nTo make sure, `as_event_loop_get` is really a problem. I wrote simple event loop programm attached as `ev_loop.txt`\r\n[ev_loop.txt](https://github.com/aerospike/aerospike-client-c/files/603838/ev_loop.txt)\r\n\r\nPlease have a look. I really appreciate any help that you can provide.\r\n\r\nThanks and Regards,\r\nPrasad"},"comment":{"url":"https://api.github.com/repos/aerospike/aerospike-client-c/issues/comments/262161543","html_url":"https://github.com/aerospike/aerospike-client-c/issues/49#issuecomment-262161543","issue_url":"https://api.github.com/repos/aerospike/aerospike-client-c/issues/49","id":262161543,"user":{"login":"prasad-joshi","id":423167,"avatar_url":"https://avatars.githubusercontent.com/u/423167?v=3","gravatar_id":"","url":"https://api.github.com/users/prasad-joshi","html_url":"https://github.com/prasad-joshi","followers_url":"https://api.github.com/users/prasad-joshi/followers","following_url":"https://api.github.com/users/prasad-joshi/following{/other_user}","gists_url":"https://api.github.com/users/prasad-joshi/gists{/gist_id}","starred_url":"https://api.github.com/users/prasad-joshi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prasad-joshi/subscriptions","organizations_url":"https://api.github.com/users/prasad-joshi/orgs","repos_url":"https://api.github.com/users/prasad-joshi/repos","events_url":"https://api.github.com/users/prasad-joshi/events{/privacy}","received_events_url":"https://api.github.com/users/prasad-joshi/received_events","type":"User","site_admin":false},"created_at":"2016-11-22T06:48:52Z","updated_at":"2016-11-22T06:48:52Z","body":"Thanks a lot for immediate response. Sorry I did not share details about my development environment.\r\n\r\nHere are the details\r\n```\r\n# lsb_release -a\r\nNo LSB modules are available.\r\nDistributor ID:\tUbuntu\r\nDescription:\tUbuntu 16.04.1 LTS\r\nRelease:\t16.04\r\nCodename:\txenial\r\n\r\n# dpkg -l | grep -i aero\r\nii  aerospike-client-c-libev-devel    4.1.2    amd64    Aerospike Client Development with libev\r\n```\r\nLike you suggested, removed as_monitor code.\r\n```\r\n# gcc -o ev_loop ev_loop.c -ggdb -laerospike -lssl -lcrypto -lpthread -lm -lz -lev\r\n\r\n# ulimit -c unlimited\r\n\r\n# ./ev_loop 192.168.2.14\r\ne = 0x1783030 loop = 0x1784100, next = 0x1 c = 0x1783030\r\nSegmentation fault (core dumped)\r\n\r\n# ls core\r\ncore\r\n```\r\n\r\nDebugging core file shows link list is corrupt\r\n```\r\nroot@ubuntu-template:~/sources# gdb ./ev_loop core\r\n...\r\n...\r\n(gdb) bt\r\n#0  0x0000000000402af7 in as_event_loop_get () at /usr/include/aerospike/as_event.h:223\r\n#1  0x0000000000402e36 in main (argc=2, argv=0x7ffc4d9fa908) at ev_loop.c:100\r\n\r\n(gdb) frame 0\r\n#0  0x0000000000402af7 in as_event_loop_get () at /usr/include/aerospike/as_event.h:223\r\n223\t\tas_event_loop_current = event_loop->next;\r\n\r\n(gdb) print event_loop\r\n$1 = (as_event_loop *) 0x1\r\n\r\n(gdb) print as_event_loops[0]\r\n$2 = {loop = 0x1784100, next = 0x1, lock = {__data = {__lock = 0, __count = 0, __owner = 24653872, __nusers = 0, __kind = 204278650, __spins = 32516, \r\n      __elision = 0, __list = {__prev = 0x0, __next = 0x1783030}}, \r\n    __size = \"\\000\\000\\000\\000\\000\\000\\000\\000\\060\\060x\\001\\000\\000\\000\\000z\\v-\\f\\004\\177\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\060\\060x\\001\\000\\000\\000\", \r\n    __align = 0}, queue = {data = 0x0, capacity = 0, head = 0, tail = 0, item_size = 0, total = 0, flags = 0}, pipe_cb_queue = {data = 0x0, capacity = 24660032, \r\n    head = 0, tail = 256, item_size = 0, total = 0, flags = 8}, thread = 4294967296, index = 24654064, pipe_cb_calling = false}\r\n\r\n(gdb) print i\r\n$1 = 1  <<<< first as_event_loop_get() was successful.\r\n```\r\nUploading complete code, executable, and core file.\r\n[aero-client.zip](https://github.com/aerospike/aerospike-client-c/files/605646/aero-client.zip)\r\n\r\nCould this be problem with 4.1.2 version of the lib? Shall I use library from latest master instead? Please let me know if you need more information from my side.\r\n\r\nThanks and Regards,\r\nPrasad\r\n"}}
{"actor":{"display_login":"prasad-joshi"}}