{"action":"created","issue":{"url":"https://api.github.com/repos/warmcat/libwebsockets/issues/489","repository_url":"https://api.github.com/repos/warmcat/libwebsockets","labels_url":"https://api.github.com/repos/warmcat/libwebsockets/issues/489/labels{/name}","comments_url":"https://api.github.com/repos/warmcat/libwebsockets/issues/489/comments","events_url":"https://api.github.com/repos/warmcat/libwebsockets/issues/489/events","html_url":"https://github.com/warmcat/libwebsockets/issues/489","id":147034722,"number":489,"title":"segfault when running libwebsockets-test-server in gdb","user":{"login":"ABruines","id":13709282,"avatar_url":"https://avatars.githubusercontent.com/u/13709282?v=3","gravatar_id":"","url":"https://api.github.com/users/ABruines","html_url":"https://github.com/ABruines","followers_url":"https://api.github.com/users/ABruines/followers","following_url":"https://api.github.com/users/ABruines/following{/other_user}","gists_url":"https://api.github.com/users/ABruines/gists{/gist_id}","starred_url":"https://api.github.com/users/ABruines/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ABruines/subscriptions","organizations_url":"https://api.github.com/users/ABruines/orgs","repos_url":"https://api.github.com/users/ABruines/repos","events_url":"https://api.github.com/users/ABruines/events{/privacy}","received_events_url":"https://api.github.com/users/ABruines/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":35,"created_at":"2016-04-08T20:42:36Z","updated_at":"2016-04-11T13:00:41Z","closed_at":null,"body":"I think that libwebsockets may have an inverse heisenbug.\r\n\r\nWhen running in gdb, 'libwebsockets-test-server --ssl' segfaults as soon\r\nas a connection is made with a webbrowser.\r\nWhen executing the test server without gdb it runs just fine...\r\nThis makes it very hard to debug any program that uses libwebsockets\r\n\r\nThe segfault allways occurs at the same point, here is the stack-trace:\r\n\r\n\r\nwrite () at ../sysdeps/unix/syscall-template.S:81\r\nsock_write (b=0x7fffec04b5a0, in=0x7fffec09ba93 \"\\025\\003\\003\", inl=31) at bss_sock.c:155\r\nBIO_write (b=0x7fffec04b5a0, in=0x7fffec09ba93, inl=31) at bio_lib.c:243\r\nssl3_write_pending (s=0x7fffec04a590, type=21, buf=0x7fffec049258 \"\\001\", len=2) at s3_pkt.c:1105\r\ndo_ssl3_write (s=0x7fffec04a590, type=21, buf=0x7fffec049258 \"\\001\", len=2, create_empty_fragment=0) at s3_pkt.c:1080\r\nssl3_dispatch_alert (s=0x7fffec04a590) at s3_pkt.c:1721\r\nssl3_send_alert (s=0x7fffec04a590, level=1, desc=0) at s3_pkt.c:1707\r\nssl3_shutdown (s=0x7fffec04a590) at s3_lib.c:4361\r\nSSL_shutdown (s=0x7fffec04a590) at ssl_lib.c:1064\r\nlws_ssl_close (wsi=0x7fffec03b440) at libwebsockets/lib/ssl.c:652\r\nlws_close_free_wsi_final (wsi=0x7fffec03b440) at libwebsockets/lib/libwebsockets.c:447\r\nlws_close_free_wsi (wsi=0x7fffec03b440, reason=LWS_CLOSE_STATUS_NOSTATUS) at libwebsockets/lib/libwebsockets.c:439\r\nlws_server_socket_service (context=0x7fffec001770, wsi=0x7fffec03b440, pollfd=0x7ffff7f40028) at libwebsockets/lib/server.c:1064\r\nlws_service_fd_tsi (context=0x7fffec001770, pollfd=0x7ffff7f40028, tsi=0) at libwebsockets/lib/service.c:603\r\nlws_plat_service_tsi (context=0x7fffec001770, timeout_ms=0, tsi=0) at libwebsockets/lib/lws-plat-unix.c:185\r\nlws_plat_service (context=0x7fffec001770, timeout_ms=50) at libwebsockets/lib/lws-plat-unix.c:199\r\nlws_service (context=0x7fffec001770, timeout_ms=50) at libwebsockets/lib/service.c:885\r\nmain (argc=2, argv=0x7fffffffe058) at libwebsockets/test-server/test-server.c:422\r\n\r\n\r\nMy copy of libwebsockets was confugured with:\r\ncmake -DLWS_SSL_SERVER_WITH_ECDH_CERT=1 -DLWS_HAVE_OPENSSL_ECDH_H=1 -DCMAKE_BUILD_TYPE=Debug ..\r\n\r\nAnd build/tested on Debian Jessie (amd64)\r\nSo far, I've been unable to figure out what causes this.\r\n"},"comment":{"url":"https://api.github.com/repos/warmcat/libwebsockets/issues/comments/208328887","html_url":"https://github.com/warmcat/libwebsockets/issues/489#issuecomment-208328887","issue_url":"https://api.github.com/repos/warmcat/libwebsockets/issues/489","id":208328887,"user":{"login":"lws-team","id":15154525,"avatar_url":"https://avatars.githubusercontent.com/u/15154525?v=3","gravatar_id":"","url":"https://api.github.com/users/lws-team","html_url":"https://github.com/lws-team","followers_url":"https://api.github.com/users/lws-team/followers","following_url":"https://api.github.com/users/lws-team/following{/other_user}","gists_url":"https://api.github.com/users/lws-team/gists{/gist_id}","starred_url":"https://api.github.com/users/lws-team/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lws-team/subscriptions","organizations_url":"https://api.github.com/users/lws-team/orgs","repos_url":"https://api.github.com/users/lws-team/repos","events_url":"https://api.github.com/users/lws-team/events{/privacy}","received_events_url":"https://api.github.com/users/lws-team/received_events","type":"User","site_admin":false},"created_at":"2016-04-11T13:00:41Z","updated_at":"2016-04-11T13:00:41Z","body":"Ok the invalid socket things is a red herring, in connection mode LWSCM_SSL_ACK_PENDING, the socket_fd is ignored.  So you definitely don't need the patch that breaks things I posted a few posts ago.\r\n\r\nAt any rate feeding the test server valid certs and keys using the commandline, and giving it LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT defeats the connection (as it should with no client cert presented) but there is no crash.\r\n\r\nIs that different for you?"}}