{"action":"created","issue":{"url":"https://api.github.com/repos/warmcat/libwebsockets/issues/555","repository_url":"https://api.github.com/repos/warmcat/libwebsockets","labels_url":"https://api.github.com/repos/warmcat/libwebsockets/issues/555/labels{/name}","comments_url":"https://api.github.com/repos/warmcat/libwebsockets/issues/555/comments","events_url":"https://api.github.com/repos/warmcat/libwebsockets/issues/555/events","html_url":"https://github.com/warmcat/libwebsockets/issues/555","id":158355069,"number":555,"title":"[Win10] Heap Corruption Exception (0xC0000374) on HTTP request with lwsws","user":{"login":"alexgille","id":1503583,"avatar_url":"https://avatars.githubusercontent.com/u/1503583?v=3","gravatar_id":"","url":"https://api.github.com/users/alexgille","html_url":"https://github.com/alexgille","followers_url":"https://api.github.com/users/alexgille/followers","following_url":"https://api.github.com/users/alexgille/following{/other_user}","gists_url":"https://api.github.com/users/alexgille/gists{/gist_id}","starred_url":"https://api.github.com/users/alexgille/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexgille/subscriptions","organizations_url":"https://api.github.com/users/alexgille/orgs","repos_url":"https://api.github.com/users/alexgille/repos","events_url":"https://api.github.com/users/alexgille/events{/privacy}","received_events_url":"https://api.github.com/users/alexgille/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":17,"created_at":"2016-06-03T12:21:44Z","updated_at":"2016-06-03T14:15:26Z","closed_at":null,"body":"Hi @lws-team,\r\n\r\nI'm experiencing a fatal _Heap Corruption Exception (0xC0000374)_ on my **Win32** executable.\r\n\r\n![3683 clip_image001_394cb0f4](https://cloud.githubusercontent.com/assets/1503583/15778007/bc3f3cf0-2993-11e6-91af-101e769e6380.jpg)\r\n\r\nThe exception is raised unexpectedly after an HTTP request to load web content (html, js, css); no web socket is involved. The behaviour is unpredictable; sometimes it's raised on an HTTP request after 5 minutes of execution, sometime after an hour.\r\n\r\nThe only relation I've found so far with HTTP requests is that there's a higher probability to reproduce this issue (and have a heap corrupted) when the server waited a long time without answering to any HTTP request, but it is still impossible to reproduce it everytime.\r\n\r\nMy program crashes without any console output when run in regular console, but raises the exception when run in a Visual Studio 2015 debugger. I don't have a strong Win32-debugging knowledge so the issue might be on my side (e.g. the way I use libwebsockets).\r\n\r\nTo help you :\r\n\r\n**conf files**\r\n```\r\n// conf\r\n{\r\n\t\"global\": {\r\n\t\t\"count-threads\": \"1\",\r\n\t\t\"server-string\": \"lwsws\",\r\n\t\t\"init-ssl\": \"yes\"\r\n\t}\r\n}\r\n\r\n// vhost\r\n{\r\n    \"vhosts\": [{\r\n        \"name\": \"localhost\",\r\n        \"port\": \"80\",\r\n        \"mounts\": [{\r\n            \"mountpoint\": \"/\",\r\n            \"origin\": \"file://C:/dev/WebDisplayCtrlSolution/WebSources/\",\r\n            \"default\": \"index.html\"\r\n        }],\r\n\t\t\"ws-protocols\": [{\r\n\t\t\t\"wdc_protocol\": {\r\n\t\t\t\t\"default\": \"1\"\r\n\t\t\t}\r\n\t\t}]\r\n    }]\r\n}\r\n```\r\n\r\n**main.c - slightly different from lwsws.c**\r\n```\r\n#include <signal.h>\r\n#include <libwebsockets.h>\r\n\r\nstatic struct lws_context *context;\r\n\r\n#define LWSWS_CONFIG_STRING_SIZE (32 * 1024)\r\n\r\nstatic const char * const plugin_dirs[] = {\r\n\t\"C:/dev/WebDisplayCtrlSolution/Debug/plugins\",\r\n\tNULL\r\n};\r\n\r\nvoid signal_cb(int signum)\r\n{\r\n\tlwsl_err(\"Signal %d caught, exiting...\\n\", signum);\r\n\tlws_libuv_stop(context);\r\n}\r\n\r\nint _tmain(int argc, _TCHAR* argv[])\r\n{\r\n\tstruct lws_context_creation_info info;\r\n\tchar *cs;\r\n\tint opts = 0, cs_len = LWSWS_CONFIG_STRING_SIZE - 1;\r\n\r\n\tint debug_level = 7;\r\n\tchar config_dir[128];\r\n\tchar *config_strings;\r\n\r\n\tmemset(&info, 0, sizeof info);\r\n\tstrcpy(config_dir, \"C:/dev/WebDisplayCtrlSolution/Debug\");\r\n\r\n\tlws_set_log_level(debug_level, lwsl_emit_syslog);\r\n\r\n\tlwsl_notice(\"lwsws libwebsockets web server - license GPL2.1\\n\");\r\n\tlwsl_notice(\"(C) Copyright 2010-2016 Andy Green <andy@warmcat.com>\\n\");\r\n\r\n\tcs = config_strings = (char *) malloc(LWSWS_CONFIG_STRING_SIZE);\r\n\tif (!config_strings) {\r\n\t\tlwsl_err(\"Unable to allocate config strings heap\\n\");\r\n\t\treturn -1;\r\n\t}\r\n\r\n\tsignal(SIGINT, signal_cb);\r\n\r\n\tinfo.max_http_header_pool = 16;\r\n\tinfo.options = opts | LWS_SERVER_OPTION_VALIDATE_UTF8 |\r\n\t\tLWS_SERVER_OPTION_EXPLICIT_VHOSTS |\r\n\t\tLWS_SERVER_OPTION_LIBUV;\r\n\r\n\tinfo.plugin_dirs = plugin_dirs;\r\n\tlwsl_notice(\"Using config dir: \\\"%s\\\"\\n\", config_dir);\r\n\r\n\tif (lwsws_get_config_globals(&info, config_dir, &cs, &cs_len)) {\r\n\t\tfree(config_strings);\r\n\t\treturn 1;\r\n\t}\r\n\r\n\tcontext = lws_create_context(&info);\r\n\tif (context == NULL) {\r\n\t\tlwsl_err(\"libwebsocket init failed\\n\");\r\n\t\tfree(config_strings);\r\n\t\treturn 1;\r\n\t}\r\n\r\n\tif (!lwsws_get_config_vhosts(context, &info, config_dir, &cs, &cs_len)) {\r\n           // no libuv signal handler\r\n\t\tlws_uv_sigint_cfg(context, 0, NULL);\r\n\t\tlws_uv_initloop(context, NULL, 0);\r\n\r\n\t\tlws_libuv_run(context, 0);\r\n\t}\r\n\r\n\tlws_context_destroy(context);\r\n\tfree(config_strings);\r\n\r\n\tfprintf(stderr, \"lwsws exited cleanly\\n\");\r\n\r\n\treturn 0;\r\n}\r\n```\r\n\r\n**console output**\r\n```\r\n[2016/05/03 11:40:58:1468] NOTICE: lwsws libwebsockets web server - license GPL2.1\r\n[2016/05/03 11:40:58:1473] NOTICE: (C) Copyright 2010-2016 Andy Green <andy@warmcat.com>\r\n[2016/05/03 11:40:58:1473] NOTICE: Using config dir: \"C:/dev/WebDisplayCtrlSolution/Debug\"\r\n[2016/05/03 11:40:58:1548] NOTICE: Initial logging level 7\r\n[2016/05/03 11:40:58:1548] NOTICE: Libwebsockets version: 2.0.0 desktop-kevdfjd\\cm3@DESKTOP-KEVDFJD-\r\n[2016/05/03 11:40:58:1553] NOTICE: IPV6 not compiled in\r\n[2016/05/03 11:40:58:1553] NOTICE: libev support not compiled in\r\n[2016/05/03 11:40:58:1553] NOTICE: libuv support compiled in and enabled\r\n[2016/05/03 11:40:58:1553] NOTICE:  Threads: 1 each 30000 fds\r\n[2016/05/03 11:40:58:1573] NOTICE:   Plugins:\r\n[2016/05/03 11:40:58:1573] NOTICE:   Scanning C:/dev/WebDisplayCtrlSolution/Debug/plugins\r\n[2016/05/03 11:40:58:1578] NOTICE:    protocol_dumb_increment.dll\r\n[2016/05/03 11:40:58:1593] NOTICE:    WDCProtocol.dll\r\n[2016/05/03 11:40:58:1644] NOTICE:  Compiled with OpenSSL support\r\n[2016/05/03 11:40:58:1754] NOTICE:  mem: per-conn:          656 bytes + protocol rx buf\r\n[2016/05/03 11:40:58:1889] NOTICE:  canonical_hostname = DESKTOP-KEVDFJD\r\n[2016/05/03 11:40:58:1894] ERR: ----file://C:/dev/WebDisplayCtrlSolution/WebSources/\r\n[2016/05/03 11:40:58:1894] NOTICE:   adding protocol wdc_protocol\r\n[2016/05/03 11:40:58:1899] NOTICE: Creating Vhost 'localhost' port 80, 2 protocols\r\n[2016/05/03 11:40:58:1899] NOTICE:    mounting file://C:/dev/WebDisplayCtrlSolution/WebSources/ to /\r\n[2016/05/03 11:40:58:1899] NOTICE:  Using non-SSL mode\r\n[2016/05/03 11:40:58:7273] NOTICE: lws_protocol_init\r\n[2016/05/03 11:40:58:7279] NOTICE:     vh localhost prot wdc_protocol opt default\r\n[2016/05/03 11:40:58:7284] NOTICE: Setting default protocol for vh localhost to wdc_protocol\r\n[2016/05/03 11:40:58:7284] NOTICE: ### protocol init\r\n```\r\n\r\nRegards"},"comment":{"url":"https://api.github.com/repos/warmcat/libwebsockets/issues/comments/223590315","html_url":"https://github.com/warmcat/libwebsockets/issues/555#issuecomment-223590315","issue_url":"https://api.github.com/repos/warmcat/libwebsockets/issues/555","id":223590315,"user":{"login":"alexgille","id":1503583,"avatar_url":"https://avatars.githubusercontent.com/u/1503583?v=3","gravatar_id":"","url":"https://api.github.com/users/alexgille","html_url":"https://github.com/alexgille","followers_url":"https://api.github.com/users/alexgille/followers","following_url":"https://api.github.com/users/alexgille/following{/other_user}","gists_url":"https://api.github.com/users/alexgille/gists{/gist_id}","starred_url":"https://api.github.com/users/alexgille/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexgille/subscriptions","organizations_url":"https://api.github.com/users/alexgille/orgs","repos_url":"https://api.github.com/users/alexgille/repos","events_url":"https://api.github.com/users/alexgille/events{/privacy}","received_events_url":"https://api.github.com/users/alexgille/received_events","type":"User","site_admin":false},"created_at":"2016-06-03T14:15:26Z","updated_at":"2016-06-03T14:15:26Z","body":"Full report : [results_latest.txt](https://github.com/warmcat/libwebsockets/files/297709/results_latest.txt)\r\n"}}
{"actor":{"display_login":"alexgille"}}