{"action":"created","issue":{"url":"https://api.github.com/repos/jackaudio/jack2/issues/140","labels_url":"https://api.github.com/repos/jackaudio/jack2/issues/140/labels{/name}","comments_url":"https://api.github.com/repos/jackaudio/jack2/issues/140/comments","events_url":"https://api.github.com/repos/jackaudio/jack2/issues/140/events","html_url":"https://github.com/jackaudio/jack2/issues/140","id":104647137,"number":140,"title":" Segmentation fault in jack library","user":{"login":"corfuvalentin","id":5146655,"avatar_url":"https://avatars.githubusercontent.com/u/5146655?v=3","gravatar_id":"","url":"https://api.github.com/users/corfuvalentin","html_url":"https://github.com/corfuvalentin","followers_url":"https://api.github.com/users/corfuvalentin/followers","following_url":"https://api.github.com/users/corfuvalentin/following{/other_user}","gists_url":"https://api.github.com/users/corfuvalentin/gists{/gist_id}","starred_url":"https://api.github.com/users/corfuvalentin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corfuvalentin/subscriptions","organizations_url":"https://api.github.com/users/corfuvalentin/orgs","repos_url":"https://api.github.com/users/corfuvalentin/repos","events_url":"https://api.github.com/users/corfuvalentin/events{/privacy}","received_events_url":"https://api.github.com/users/corfuvalentin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-03T08:34:35Z","updated_at":"2015-09-03T08:54:08Z","closed_at":null,"body":"Hi,\r\nI observed one segmentation fault in this library:\r\n\r\n    Program terminated with signal 11, Segmentation fault. \r\n    #0  0xb6be5656 in sem_getvalue@GLIBC_2.0 () from /lib/libpthread.so.0 \r\n    (gdb) bt \r\n    #0  0xb6be5656 in sem_getvalue@GLIBC_2.0 () from /lib/libpthread.so.0 \r\n    #1  0xb67b9ef0 in Jack::JackPosixSemaphore::ConnectInput(char const*, char const*) () from /usr/lib/libjack.so.0 \r\n    #2  0xb67bc418 in Jack::JackLibClient::ClientNotifyImp(int, char const*, int, int, char const*, int, int) () from /usr/lib/libjack.so.0 \r\n    #3  0xb679c02a in Jack::JackClient::ClientNotify(int, char const*, int, int, char const*, int, int) () \r\n    from /usr/lib/libjack.so.0 \r\n    #4  0xb67be5d1 in Jack::JackSocketClientChannel::Execute() () from /usr/lib/libjack.so.0 \r\n    #5  0xb67b8fe5 in Jack::JackPosixThread::ThreadHandler(void*) () from /usr/lib/libjack.so.0 \r\n    #6  0xb6bdee19 in start_thread () from /lib/libpthread.so.0 \r\n    #7  0xb6a3cffe in clone () from /lib/libc.so.6 \r\n    (gdb)\r\n\r\n\r\nI'm also think that the seg fault is due to sem_getvalue() of NULL semaphore.\r\nSo I'm suggesting this kind of fix...\r\n\r\n    diff --git a/posix/JackPosixSemaphore.cpp b/posix/JackPosixSemaphore.cpp\r\n    index 63e0e8f..7969b7f 100644\r\n    --- a/posix/JackPosixSemaphore.cpp\r\n    +++ b/posix/JackPosixSemaphore.cpp\r\n    @@ -166,11 +166,14 @@ bool JackPosixSemaphore::ConnectInput(const char* name, const char* server_name)\r\n     if ((fSemaphore = sem_open(fName, O_CREAT)) == (sem_t*)SEM_FAILED) {\r\n         jack_error(\"Connect: can't connect named semaphore name = %s err = %s\", fName, strerror(errno));\r\n         return false;\r\n    -    } else {\r\n    +    } else if (fSemaphore){\r\n         int val = 0;\r\n         sem_getvalue(fSemaphore, &val);\r\n         jack_log(\"JackPosixSemaphore::Connect sem_getvalue %ld\", val);\r\n         return true;\r\n    +    } else {\r\n    +        jack_err(\"ackPosixSemaphore::Connect sem_getvalue: not initialized!\");\r\n    +        return false;\r\n       }\r\n    }\r\n\r\n\r\nWhat do you think?\r\n\r\n(I'm using jack version 1.9.9.5.)\r\n\r\nBest Regards,\r\nValentin Corfu"},"comment":{"url":"https://api.github.com/repos/jackaudio/jack2/issues/comments/137381894","html_url":"https://github.com/jackaudio/jack2/issues/140#issuecomment-137381894","issue_url":"https://api.github.com/repos/jackaudio/jack2/issues/140","id":137381894,"user":{"login":"sletz","id":1430487,"avatar_url":"https://avatars.githubusercontent.com/u/1430487?v=3","gravatar_id":"","url":"https://api.github.com/users/sletz","html_url":"https://github.com/sletz","followers_url":"https://api.github.com/users/sletz/followers","following_url":"https://api.github.com/users/sletz/following{/other_user}","gists_url":"https://api.github.com/users/sletz/gists{/gist_id}","starred_url":"https://api.github.com/users/sletz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sletz/subscriptions","organizations_url":"https://api.github.com/users/sletz/orgs","repos_url":"https://api.github.com/users/sletz/repos","events_url":"https://api.github.com/users/sletz/events{/privacy}","received_events_url":"https://api.github.com/users/sletz/received_events","type":"User","site_admin":false},"created_at":"2015-09-03T08:54:08Z","updated_at":"2015-09-03T08:54:08Z","body":"OK. Fixed on git.\n\nSt�phane\n\nLe 3 sept. 2015 � 10:34, Valentin Corfu <notifications@github.com> a �crit :\n\n> Hi,\n> I observed one segmentation fault in this library:\n> \n> Program terminated with signal 11, Segmentation fault. \n> #0  0xb6be5656 in sem_getvalue@GLIBC_2.0 () from /lib/libpthread.so.0 \n> (gdb) bt \n> #0  0xb6be5656 in sem_getvalue@GLIBC_2.0 () from /lib/libpthread.so.0 \n> #1  0xb67b9ef0 in Jack::JackPosixSemaphore::ConnectInput(char const*, char const*) () from /usr/lib/libjack.so.0 \n> #2  0xb67bc418 in Jack::JackLibClient::ClientNotifyImp(int, char const*, int, int, char const*, int, int) () from /usr/lib/libjack.so.0 \n> #3  0xb679c02a in Jack::JackClient::ClientNotify(int, char const*, int, int, char const*, int, int) () \n> from /usr/lib/libjack.so.0 \n> #4  0xb67be5d1 in Jack::JackSocketClientChannel::Execute() () from /usr/lib/libjack.so.0 \n> #5  0xb67b8fe5 in Jack::JackPosixThread::ThreadHandler(void*) () from /usr/lib/libjack.so.0 \n> #6  0xb6bdee19 in start_thread () from /lib/libpthread.so.0 \n> #7  0xb6a3cffe in clone () from /lib/libc.so.6 \n> (gdb)\n> \n> I'm also think that the seg fault is due to sem_getvalue() of NULL semaphore.\n> So I'm suggesting this kind of fix...\n> \n> diff --git a/posix/JackPosixSemaphore.cpp b/posix/JackPosixSemaphore.cpp\n> index 63e0e8f..7969b7f 100644\n> --- a/posix/JackPosixSemaphore.cpp\n> +++ b/posix/JackPosixSemaphore.cpp\n> @@ -166,11 +166,14 @@ bool JackPosixSemaphore::ConnectInput(const char* name, const char* server_name)\n>  if ((fSemaphore = sem_open(fName, O_CREAT)) == (sem_t*)SEM_FAILED) {\n>      jack_error(\"Connect: can't connect named semaphore name = %s err = %s\", fName, strerror(errno));\n>      return false;\n> -    } else {\n> +    } else if (fSemaphore){\n>      int val = 0;\n>      sem_getvalue(fSemaphore, &val);\n>      jack_log(\"JackPosixSemaphore::Connect sem_getvalue %ld\", val);\n>      return true;\n> +    } else {\n> +        jack_err(\"ackPosixSemaphore::Connect sem_getvalue: not initialized!\");\n> +        return false;\n>    }\n> }\n> \n> What do you think?\n> \n> (I'm using jack version 1.9.9.5.)\n> \n> Best Regards,\n> Valentin Corfu\n> \n> �\n> Reply to this email directly or view it on GitHub.\n> \n\n"}}