{"action":"created","issue":{"url":"https://api.github.com/repos/sysown/proxysql/issues/715","repository_url":"https://api.github.com/repos/sysown/proxysql","labels_url":"https://api.github.com/repos/sysown/proxysql/issues/715/labels{/name}","comments_url":"https://api.github.com/repos/sysown/proxysql/issues/715/comments","events_url":"https://api.github.com/repos/sysown/proxysql/issues/715/events","html_url":"https://github.com/sysown/proxysql/issues/715","id":181579026,"number":715,"title":"ProxySQL segfaults when configured with servers outside the hosts network on alpine linux","user":{"login":"ryanschwartz","id":4556,"avatar_url":"https://avatars.githubusercontent.com/u/4556?v=3","gravatar_id":"","url":"https://api.github.com/users/ryanschwartz","html_url":"https://github.com/ryanschwartz","followers_url":"https://api.github.com/users/ryanschwartz/followers","following_url":"https://api.github.com/users/ryanschwartz/following{/other_user}","gists_url":"https://api.github.com/users/ryanschwartz/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanschwartz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanschwartz/subscriptions","organizations_url":"https://api.github.com/users/ryanschwartz/orgs","repos_url":"https://api.github.com/users/ryanschwartz/repos","events_url":"https://api.github.com/users/ryanschwartz/events{/privacy}","received_events_url":"https://api.github.com/users/ryanschwartz/received_events","type":"User","site_admin":false},"labels":[{"id":152884416,"url":"https://api.github.com/repos/sysown/proxysql/labels/bug","name":"bug","color":"fc2929","default":true},{"id":228952817,"url":"https://api.github.com/repos/sysown/proxysql/labels/MONITOR","name":"MONITOR","color":"eb6420","default":false}],"state":"open","locked":false,"assignee":{"login":"renecannao","id":3645227,"avatar_url":"https://avatars.githubusercontent.com/u/3645227?v=3","gravatar_id":"","url":"https://api.github.com/users/renecannao","html_url":"https://github.com/renecannao","followers_url":"https://api.github.com/users/renecannao/followers","following_url":"https://api.github.com/users/renecannao/following{/other_user}","gists_url":"https://api.github.com/users/renecannao/gists{/gist_id}","starred_url":"https://api.github.com/users/renecannao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renecannao/subscriptions","organizations_url":"https://api.github.com/users/renecannao/orgs","repos_url":"https://api.github.com/users/renecannao/repos","events_url":"https://api.github.com/users/renecannao/events{/privacy}","received_events_url":"https://api.github.com/users/renecannao/received_events","type":"User","site_admin":false},"assignees":[{"login":"renecannao","id":3645227,"avatar_url":"https://avatars.githubusercontent.com/u/3645227?v=3","gravatar_id":"","url":"https://api.github.com/users/renecannao","html_url":"https://github.com/renecannao","followers_url":"https://api.github.com/users/renecannao/followers","following_url":"https://api.github.com/users/renecannao/following{/other_user}","gists_url":"https://api.github.com/users/renecannao/gists{/gist_id}","starred_url":"https://api.github.com/users/renecannao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renecannao/subscriptions","organizations_url":"https://api.github.com/users/renecannao/orgs","repos_url":"https://api.github.com/users/renecannao/repos","events_url":"https://api.github.com/users/renecannao/events{/privacy}","received_events_url":"https://api.github.com/users/renecannao/received_events","type":"User","site_admin":false}],"milestone":null,"comments":10,"created_at":"2016-10-07T03:41:05Z","updated_at":"2016-11-29T22:23:27Z","closed_at":null,"body":"We run apps in alpine containers on Google Container Engine, which is essentially a hosted kubernetes infrastructure. We run would like to run proxysql inside these containers as a database proxy layer.\n\nI've run into a problem where proxysql will run for ~10 seconds, then it segfaults, but the only time it does so is if there are servers in the mysql_servers configuration block that exist in other sub-networks. For example from a client at 10.128.0.2 running proxysql with servers 10.128.0.3 and 10.128.0.4, proxysql runs fine. When I add 10.140.0.3 as a server, proxysql segfaults after 10s.\n\nI've confirmed network connectivity is allowed.\n\nI've run proxysql under gdb and it seems that the segfaults occur in MySQL_Monitor.cpp at line 167 or 173: \n\n```\nThread 8 \"proxysql\" received signal SIGSEGV, Segmentation fault.\n[Switching to LWP 145]\nMySQL_Monitor_Connection_Pool::purge_idle_connections (this=0x555555aa0800) at MySQL_Monitor.cpp:167\n167 MySQL_Monitor.cpp: No such file or directory.\n(gdb) thread apply 8 bt\n\nThread 8 (LWP 145):\n#0  MySQL_Monitor_Connection_Pool::purge_idle_connections (this=0x555555aa0800) at MySQL_Monitor.cpp:167\n#1  0x00005555555ece9c in MySQL_Monitor::run (this=0x555555aa0740) at MySQL_Monitor.cpp:1465\n#2  0x00007ffff7242c8a in execute_native_thread_routine () from /usr/lib/libstdc++.so.6\n#3  0x00007ffff7dc44fc in ?? () from /lib/ld-musl-x86_64.so.1\n#4  0x0000000000000000 in ?? ()\n```\n\n```\nThread 8 \"proxysql\" received signal SIGSEGV, Segmentation fault.\n[Switching to LWP 46]\nMySQL_Monitor_Connection_Pool::purge_idle_connections (this=0x555555aa82c0) at MySQL_Monitor.cpp:173\n173 MySQL_Monitor.cpp: No such file or directory.\n(gdb) thread apply 8 bt\n\nThread 8 (LWP 46):\n#0  MySQL_Monitor_Connection_Pool::purge_idle_connections (this=0x555555aa82c0) at MySQL_Monitor.cpp:173\n#1  0x00005555555ece9c in MySQL_Monitor::run (this=0x555555aa8200) at MySQL_Monitor.cpp:1465\n#2  0x00007ffff7242c8a in execute_native_thread_routine () from /usr/lib/libstdc++.so.6\n#3  0x00007ffff7dc44fc in ?? () from /lib/ld-musl-x86_64.so.1\n#4  0x0000000000000000 in ?? ()\n```\n\nThe other common segfault occurs here:\n\n```\nThread 8 \"proxysql\" received signal SIGSEGV, Segmentation fault.\n[Switching to LWP 121]\n0x00007ffff7dc2bd8 in memcpy () from /lib/ld-musl-x86_64.so.1\n(gdb) thread apply 8 bt\n\nThread 8 (LWP 121):\n#0  0x00007ffff7dc2bd8 in memcpy () from /lib/ld-musl-x86_64.so.1\n#1  0x00005555555ebb3c in memcpy (__n=8, __os=<optimized out>, __od=0x7ffff7e9a5b0) at /usr/include/fortify/string.h:51\n#2  MySQL_Monitor_Connection_Pool::purge_idle_connections (this=0x555555aa0840) at MySQL_Monitor.cpp:173\n#3  0x00005555555ece9c in MySQL_Monitor::run (this=0x555555aa0780) at MySQL_Monitor.cpp:1465\n#4  0x00007ffff7242c8a in execute_native_thread_routine () from /usr/lib/libstdc++.so.6\n#5  0x00007ffff7dc44fc in ?? () from /lib/ld-musl-x86_64.so.1\n#6  0x0000000000000000 in ?? ()\n```\n\n```\nThread 8 \"proxysql\" received signal SIGSEGV, Segmentation fault.\n[Switching to LWP 170]\n0x00007ffff7dc2bd8 in memcpy () from /lib/ld-musl-x86_64.so.1\n(gdb) thread apply 8 bt\n\nThread 8 (LWP 170):\n#0  0x00007ffff7dc2bd8 in memcpy () from /lib/ld-musl-x86_64.so.1\n#1  0x00005555555ebb3c in memcpy (__n=8, __os=<optimized out>, __od=0x7ffff7e9a5b0) at /usr/include/fortify/string.h:51\n#2  MySQL_Monitor_Connection_Pool::purge_idle_connections (this=0x555555aa0800) at MySQL_Monitor.cpp:173\n#3  0x00005555555ece9c in MySQL_Monitor::run (this=0x555555aa0740) at MySQL_Monitor.cpp:1465\n#4  0x00007ffff7242c8a in execute_native_thread_routine () from /usr/lib/libstdc++.so.6\n#5  0x00007ffff7dc44fc in ?? () from /lib/ld-musl-x86_64.so.1\n#6  0x0000000000000000 in ?? ()\n```\n\nI have confirmed that this behavior effects both 1.2.1 and 1.2.4.\n\nI'm happy to provide what further information I can, including tcpdump captures if that would be helpful.\n"},"comment":{"url":"https://api.github.com/repos/sysown/proxysql/issues/comments/263719444","html_url":"https://github.com/sysown/proxysql/issues/715#issuecomment-263719444","issue_url":"https://api.github.com/repos/sysown/proxysql/issues/715","id":263719444,"user":{"login":"ryanschwartz","id":4556,"avatar_url":"https://avatars.githubusercontent.com/u/4556?v=3","gravatar_id":"","url":"https://api.github.com/users/ryanschwartz","html_url":"https://github.com/ryanschwartz","followers_url":"https://api.github.com/users/ryanschwartz/followers","following_url":"https://api.github.com/users/ryanschwartz/following{/other_user}","gists_url":"https://api.github.com/users/ryanschwartz/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanschwartz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanschwartz/subscriptions","organizations_url":"https://api.github.com/users/ryanschwartz/orgs","repos_url":"https://api.github.com/users/ryanschwartz/repos","events_url":"https://api.github.com/users/ryanschwartz/events{/privacy}","received_events_url":"https://api.github.com/users/ryanschwartz/received_events","type":"User","site_admin":false},"created_at":"2016-11-29T22:23:27Z","updated_at":"2016-11-29T22:23:27Z","body":"1.2.5-715 would not build for me in alpine. Make fails here:\r\n\r\n```\r\n../lib/libproxysql.a(MySQL_Monitor.oo): In function `monitor_connect_pthread(void*)':\r\n/tmp/proxysql/lib/MySQL_Monitor.cpp:284: undefined reference to `mallctl'\r\n../lib/libproxysql.a(MySQL_Monitor.oo): In function `monitor_ping_pthread(void*)':\r\n/tmp/proxysql/lib/MySQL_Monitor.cpp:291: undefined reference to `mallctl'\r\n../lib/libproxysql.a(MySQL_Monitor.oo): In function `monitor_read_only_pthread(void*)':\r\n/tmp/proxysql/lib/MySQL_Monitor.cpp:298: undefined reference to `mallctl'\r\n../lib/libproxysql.a(MySQL_Monitor.oo): In function `monitor_replication_lag_pthread(void*)':\r\n/tmp/proxysql/lib/MySQL_Monitor.cpp:305: undefined reference to `mallctl'\r\n../lib/libproxysql.a(thread.oo): In function `Thread::start(bool)':\r\n/tmp/proxysql/lib/thread.cpp:53: undefined reference to `mallctl'\r\ncollect2: error: ld returned 1 exit status\r\nmake[1]: *** [proxysql] Error 1\r\nmake: *** [build_src] Error 2\r\nMakefile:66: recipe for target 'proxysql' failed\r\nmake[1]: Leaving directory '/tmp/proxysql/src'\r\nMakefile:37: recipe for target 'build_src' failed\r\n```\r\n\r\nMy updated Dockerfile is:\r\n\r\n```\r\nFROM alpine\r\n\r\nMAINTAINER Ryan Schwartz <ryan.schwartz@ingramcontent.com>\r\n\r\nWORKDIR /tmp\r\nRUN apk update && \\\r\n    apk add -t runtime-depends libgcc libstdc++ && \\\r\n    apk add -t build-depends build-base automake bzip2 patch git cmake openssl-dev libc6-compat && \\\r\n    apk add --no-cache -t edge-build-depends --repository http://dl-3.alpinelinux.org/alpine/edge/main libexecinfo-dev && \\\r\n    git clone https://github.com/sysown/proxysql.git && \\\r\n    cd proxysql && \\\r\n    git checkout v1.2.5-715 && \\\r\n    sed -i -e '/PROXYSQL_VERSION/s:1.2.4:1.2.5-715:g' include/proxysql.h && \\\r\n    NOJEMALLOC=1 make && \\\r\n    cp src/proxysql /usr/bin/proxysql && \\\r\n    apk del build-depends edge-build-depends && \\\r\n    cd && rm -rf /tmp/* /var/cache/apk/*\r\n\r\nCOPY proxysql.cnf /proxysql/proxysql.cnf\r\nRUN mkdir -p /var/lib/proxysql\r\nENTRYPOINT [\"proxysql\", \"-f\", \"-c\", \"/proxysql/proxysql.cnf\"]\r\n```"}}
{"actor":{"display_login":"ryanschwartz"}}