Open marwisihans opened 1 year ago
First move with time travelling crashes is run it under valgrind.
Sadly I don't have valgrind, only gdb because the platform is a custom build, built with yocto. But I will see what I can do!
Yocto should have a valgrind recipe you can add to your image, or unpack the build of it into your rootfs if it's mutable.
I was able to get valgrind up and running!
I could not run with flags such as "--track-origins" because it was either way to slow and/or I could not reproduce the bug with them active. This is the output where lws was present.
root@(custom-linux):~# valgrind --vgdb=yes lws_example -D
==902== Memcheck, a memory error detector
==902== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==902== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==902== Command: lws_example -D
==902==
==902== Thread 61 example LWS:
==902== Conditional jump or move depends on uninitialised value(s)
==902== at 0x4FEB42: protobuf_encode_uint32 (protobuf.c:204)
==902== by 0x6C891F: example_socket_method (example_socket.c:358)
==902== by 0x6CA40D: example_socket_default_open (example_socket_default.c:136)
==902== by 0x6C8BF4: example_socket_connected_callback (example_socket.c:438)
==902== by 0x6C47EB: example_libwebsockets_raw_callback (example_libwebsockets.c:213)
==902== by 0x4B78D36: lws_adopt_descriptor_vhost2 (adopt.c:434)
==902== by 0x4B78EE9: lws_adopt_descriptor_vhost_via_info (adopt.c:545)
==902== by 0x4B78E00: lws_adopt_descriptor_vhost (adopt.c:494)
==902== by 0x4B97543: rops_handle_POLLIN_listen (ops-listen.c:147)
==902== by 0x4B7442F: lws_service_fd_tsi (service.c:766)
==902== by 0x4B4D214: _lws_plat_service_forced_tsi (unix-service.c:51)
==902== by 0x4B4D621: _lws_plat_service_tsi (unix-service.c:216)
==902==
==902== Conditional jump or move depends on uninitialised value(s)
==902== at 0x4FEB42: protobuf_encode_uint32 (protobuf.c:204)
==902== by 0x6C98B7: example_socket_response_internal (example_socket.c:808)
==902== by 0x6CA7BD: example_socket_default_method_open_session (example_socket_default.c:238)
==902== by 0x6CA4BD: example_socket_default_method (example_socket_default.c:160)
==902== by 0x6C968B: example_socket_handle_message (example_socket.c:762)
==902== by 0x6C6BC4: example_libwebsockets_callback_receive (example_libwebsockets.c:1457)
==902== by 0x6C4817: example_libwebsockets_raw_callback (example_libwebsockets.c:216)
==902== by 0x4B75D4D: user_callback_handle_rxflow (wsi.c:498)
==902== by 0x4B96C25: rops_handle_POLLIN_raw_skt (ops-raw-skt.c:208)
==902== by 0x4B7442F: lws_service_fd_tsi (service.c:766)
==902== by 0x4B4D214: _lws_plat_service_forced_tsi (unix-service.c:51)
==902== by 0x4B4D621: _lws_plat_service_tsi (unix-service.c:216)
==902==
==902== Invalid read of size 8
==902== at 0x4B82C19: _lws_vhost_init_server_af (server.c:122)
==902== by 0x4B834AB: _lws_vhost_init_server (server.c:482)
==902== by 0x4B70538: lws_create_vhost (vhost.c:1010)
==902== by 0x6C59C4: example_libwebsockets_lws_vhost_create_callback_helper (example_libwebsockets.c:872)
==902== by 0x6C58BC: example_libwebsockets_lws_vhost_create_callback (example_libwebsockets.c:800)
==902== by 0x6C5DC5: example_libwebsockets_callback_event_wait_cancelled (example_libwebsockets.c:1042)
==902== by 0x6C4968: example_libwebsockets_http_callback (example_libwebsockets.c:301)
==902== by 0x4B76876: lws_broadcast (wsi.c:869)
==902== by 0x4B798DC: rops_handle_POLLIN_pipe (ops-pipe.c:111)
==902== by 0x4B7442F: lws_service_fd_tsi (service.c:766)
==902== by 0x4B4D214: _lws_plat_service_forced_tsi (unix-service.c:51)
==902== by 0x4B4D621: _lws_plat_service_tsi (unix-service.c:216)
==902== Address 0x2c511c00 is 592 bytes inside a block of size 854 free'd
==902== at 0x4839900: free (vg_replace_malloc.c:540)
==902== by 0x4B56FBB: _realloc (alloc.c:144)
==902== by 0x4B56FF2: lws_realloc (alloc.c:154)
==902== by 0x4B71537: __lws_vhost_destroy2 (vhost.c:1585)
==902== by 0x4B715DF: lws_vhost_destroy (vhost.c:1631)
==902== by 0x6C5B50: example_libwebsockets_lws_vhost_destroy_callback (example_libwebsockets.c:911)
==902== by 0x6C5DC5: example_libwebsockets_callback_event_wait_cancelled (example_libwebsockets.c:1042)
==902== by 0x6C4968: example_libwebsockets_http_callback (example_libwebsockets.c:301)
==902== by 0x4B76876: lws_broadcast (wsi.c:869)
==902== by 0x4B798DC: rops_handle_POLLIN_pipe (ops-pipe.c:111)
==902== by 0x4B7442F: lws_service_fd_tsi (service.c:766)
==902== by 0x4B4D214: _lws_plat_service_forced_tsi (unix-service.c:51)
==902== Block was alloc'd at
==902== at 0x4838694: malloc (vg_replace_malloc.c:308)
==902== by 0x483ABE3: realloc (vg_replace_malloc.c:836)
==902== by 0x4B56F61: _realloc (alloc.c:133)
==902== by 0x4B5701D: lws_zalloc (alloc.c:159)
==902== by 0x4B6F719: lws_create_vhost (vhost.c:599)
==902== by 0x6C59C4: example_libwebsockets_lws_vhost_create_callback_helper (example_libwebsockets.c:872)
==902== by 0x6C58BC: example_libwebsockets_lws_vhost_create_callback (example_libwebsockets.c:800)
==902== by 0x6C5597: example_libwebsockets_lws_vhost_init (example_libwebsockets.c:715)
==902== by 0x6C467C: example_libwebsockets_task (example_libwebsockets.c:175)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902==
==902== Invalid read of size 4
==902== at 0x4B7688C: lws_broadcast (wsi.c:866)
==902== by 0x4B798DC: rops_handle_POLLIN_pipe (ops-pipe.c:111)
==902== by 0x4B7442F: lws_service_fd_tsi (service.c:766)
==902== by 0x4B4D214: _lws_plat_service_forced_tsi (unix-service.c:51)
==902== by 0x4B4D621: _lws_plat_service_tsi (unix-service.c:216)
==902== by 0x4B4D684: lws_plat_service (unix-service.c:235)
==902== by 0x4B7463F: lws_service (service.c:838)
==902== by 0x6C46D9: example_libwebsockets_task (example_libwebsockets.c:185)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902== Address 0x2c511cd0 is 800 bytes inside a block of size 854 free'd
==902== at 0x4839900: free (vg_replace_malloc.c:540)
==902== by 0x4B56FBB: _realloc (alloc.c:144)
==902== by 0x4B56FF2: lws_realloc (alloc.c:154)
==902== by 0x4B71537: __lws_vhost_destroy2 (vhost.c:1585)
==902== by 0x4B715DF: lws_vhost_destroy (vhost.c:1631)
==902== by 0x6C5B50: example_libwebsockets_lws_vhost_destroy_callback (example_libwebsockets.c:911)
==902== by 0x6C5DC5: example_libwebsockets_callback_event_wait_cancelled (example_libwebsockets.c:1042)
==902== by 0x6C4968: example_libwebsockets_http_callback (example_libwebsockets.c:301)
==902== by 0x4B76876: lws_broadcast (wsi.c:869)
==902== by 0x4B798DC: rops_handle_POLLIN_pipe (ops-pipe.c:111)
==902== by 0x4B7442F: lws_service_fd_tsi (service.c:766)
==902== by 0x4B4D214: _lws_plat_service_forced_tsi (unix-service.c:51)
==902== Block was alloc'd at
==902== at 0x4838694: malloc (vg_replace_malloc.c:308)
==902== by 0x483ABE3: realloc (vg_replace_malloc.c:836)
==902== by 0x4B56F61: _realloc (alloc.c:133)
==902== by 0x4B5701D: lws_zalloc (alloc.c:159)
==902== by 0x4B6F719: lws_create_vhost (vhost.c:599)
==902== by 0x6C59C4: example_libwebsockets_lws_vhost_create_callback_helper (example_libwebsockets.c:872)
==902== by 0x6C58BC: example_libwebsockets_lws_vhost_create_callback (example_libwebsockets.c:800)
==902== by 0x6C5597: example_libwebsockets_lws_vhost_init (example_libwebsockets.c:715)
==902== by 0x6C467C: example_libwebsockets_task (example_libwebsockets.c:175)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902==
==902== Invalid read of size 8
==902== at 0x4B7689B: lws_broadcast (wsi.c:874)
==902== by 0x4B798DC: rops_handle_POLLIN_pipe (ops-pipe.c:111)
==902== by 0x4B7442F: lws_service_fd_tsi (service.c:766)
==902== by 0x4B4D214: _lws_plat_service_forced_tsi (unix-service.c:51)
==902== by 0x4B4D621: _lws_plat_service_tsi (unix-service.c:216)
==902== by 0x4B4D684: lws_plat_service (unix-service.c:235)
==902== by 0x4B7463F: lws_service (service.c:838)
==902== by 0x6C46D9: example_libwebsockets_task (example_libwebsockets.c:185)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902== Address 0x2c511b78 is 456 bytes inside a block of size 854 free'd
==902== at 0x4839900: free (vg_replace_malloc.c:540)
==902== by 0x4B56FBB: _realloc (alloc.c:144)
==902== by 0x4B56FF2: lws_realloc (alloc.c:154)
==902== by 0x4B71537: __lws_vhost_destroy2 (vhost.c:1585)
==902== by 0x4B715DF: lws_vhost_destroy (vhost.c:1631)
==902== by 0x6C5B50: example_libwebsockets_lws_vhost_destroy_callback (example_libwebsockets.c:911)
==902== by 0x6C5DC5: example_libwebsockets_callback_event_wait_cancelled (example_libwebsockets.c:1042)
==902== by 0x6C4968: example_libwebsockets_http_callback (example_libwebsockets.c:301)
==902== by 0x4B76876: lws_broadcast (wsi.c:869)
==902== by 0x4B798DC: rops_handle_POLLIN_pipe (ops-pipe.c:111)
==902== by 0x4B7442F: lws_service_fd_tsi (service.c:766)
==902== by 0x4B4D214: _lws_plat_service_forced_tsi (unix-service.c:51)
==902== Block was alloc'd at
==902== at 0x4838694: malloc (vg_replace_malloc.c:308)
==902== by 0x483ABE3: realloc (vg_replace_malloc.c:836)
==902== by 0x4B56F61: _realloc (alloc.c:133)
==902== by 0x4B5701D: lws_zalloc (alloc.c:159)
==902== by 0x4B6F719: lws_create_vhost (vhost.c:599)
==902== by 0x6C59C4: example_libwebsockets_lws_vhost_create_callback_helper (example_libwebsockets.c:872)
==902== by 0x6C58BC: example_libwebsockets_lws_vhost_create_callback (example_libwebsockets.c:800)
==902== by 0x6C5597: example_libwebsockets_lws_vhost_init (example_libwebsockets.c:715)
==902== by 0x6C467C: example_libwebsockets_task (example_libwebsockets.c:175)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902==
==902== Conditional jump or move depends on uninitialised value(s)
==902== at 0x4FEB42: protobuf_encode_uint32 (protobuf.c:204)
==902== by 0x6C98B7: example_socket_response_internal (example_socket.c:808)
==902== by 0x6CA606: example_socket_default_method_hello (example_socket_default.c:193)
==902== by 0x6CA466: example_socket_default_method (example_socket_default.c:154)
==902== by 0x6C968B: example_socket_handle_message (example_socket.c:762)
==902== by 0x6C6BC4: example_libwebsockets_callback_receive (example_libwebsockets.c:1457)
==902== by 0x6C5C72: example_libwebsockets_websocket_callback (example_libwebsockets.c:963)
==902== by 0x4B75D4D: user_callback_handle_rxflow (wsi.c:498)
==902== by 0x4B96429: lws_ws_frame_rest_is_payload (server-ws.c:970)
==902== by 0x4B9656E: lws_parse_ws (server-ws.c:1052)
==902== by 0x4B8E6D3: lws_read_h1 (ops-h1.c:270)
==902== by 0x4B9150C: rops_handle_POLLIN_ws (ops-ws.c:1183)
==902==
==902== Invalid read of size 8
==902== at 0x4B4C75E: lws_sul_plat_unix (unix-init.c:68)
==902== by 0x4B74A76: __lws_sul_service_ripe (sorted-usec-list.c:161)
==902== by 0x4B4D40C: _lws_plat_service_tsi (unix-service.c:125)
==902== by 0x4B4D684: lws_plat_service (unix-service.c:235)
==902== by 0x4B7463F: lws_service (service.c:838)
==902== by 0x6C46D9: example_libwebsockets_task (example_libwebsockets.c:185)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902== Address 0x2c511ba0 is 496 bytes inside a block of size 854 free'd
==902== at 0x4839900: free (vg_replace_malloc.c:540)
==902== by 0x4B56FBB: _realloc (alloc.c:144)
==902== by 0x4B56FF2: lws_realloc (alloc.c:154)
==902== by 0x4B71537: __lws_vhost_destroy2 (vhost.c:1585)
==902== by 0x4B715DF: lws_vhost_destroy (vhost.c:1631)
==902== by 0x6C5B50: example_libwebsockets_lws_vhost_destroy_callback (example_libwebsockets.c:911)
==902== by 0x6C5DC5: example_libwebsockets_callback_event_wait_cancelled (example_libwebsockets.c:1042)
==902== by 0x6C4968: example_libwebsockets_http_callback (example_libwebsockets.c:301)
==902== by 0x4B76876: lws_broadcast (wsi.c:869)
==902== by 0x4B798DC: rops_handle_POLLIN_pipe (ops-pipe.c:111)
==902== by 0x4B7442F: lws_service_fd_tsi (service.c:766)
==902== by 0x4B4D214: _lws_plat_service_forced_tsi (unix-service.c:51)
==902== Block was alloc'd at
==902== at 0x4838694: malloc (vg_replace_malloc.c:308)
==902== by 0x483ABE3: realloc (vg_replace_malloc.c:836)
==902== by 0x4B56F61: _realloc (alloc.c:133)
==902== by 0x4B5701D: lws_zalloc (alloc.c:159)
==902== by 0x4B6F719: lws_create_vhost (vhost.c:599)
==902== by 0x6C59C4: example_libwebsockets_lws_vhost_create_callback_helper (example_libwebsockets.c:872)
==902== by 0x6C58BC: example_libwebsockets_lws_vhost_create_callback (example_libwebsockets.c:800)
==902== by 0x6C5597: example_libwebsockets_lws_vhost_init (example_libwebsockets.c:715)
==902== by 0x6C467C: example_libwebsockets_task (example_libwebsockets.c:175)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902==
==902== Invalid read of size 4
==902== at 0x4B833DB: _lws_vhost_init_server (server.c:421)
==902== by 0x4B4C791: lws_sul_plat_unix (unix-init.c:69)
==902== by 0x4B74A76: __lws_sul_service_ripe (sorted-usec-list.c:161)
==902== by 0x4B4D40C: _lws_plat_service_tsi (unix-service.c:125)
==902== by 0x4B4D684: lws_plat_service (unix-service.c:235)
==902== by 0x4B7463F: lws_service (service.c:838)
==902== by 0x6C46D9: example_libwebsockets_task (example_libwebsockets.c:185)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902== Address 0x2c511cc8 is 792 bytes inside a block of size 854 free'd
==902== at 0x4839900: free (vg_replace_malloc.c:540)
==902== by 0x4B56FBB: _realloc (alloc.c:144)
==902== by 0x4B56FF2: lws_realloc (alloc.c:154)
==902== by 0x4B71537: __lws_vhost_destroy2 (vhost.c:1585)
==902== by 0x4B715DF: lws_vhost_destroy (vhost.c:1631)
==902== by 0x6C5B50: example_libwebsockets_lws_vhost_destroy_callback (example_libwebsockets.c:911)
==902== by 0x6C5DC5: example_libwebsockets_callback_event_wait_cancelled (example_libwebsockets.c:1042)
==902== by 0x6C4968: example_libwebsockets_http_callback (example_libwebsockets.c:301)
==902== by 0x4B76876: lws_broadcast (wsi.c:869)
==902== by 0x4B798DC: rops_handle_POLLIN_pipe (ops-pipe.c:111)
==902== by 0x4B7442F: lws_service_fd_tsi (service.c:766)
==902== by 0x4B4D214: _lws_plat_service_forced_tsi (unix-service.c:51)
==902== Block was alloc'd at
==902== at 0x4838694: malloc (vg_replace_malloc.c:308)
==902== by 0x483ABE3: realloc (vg_replace_malloc.c:836)
==902== by 0x4B56F61: _realloc (alloc.c:133)
==902== by 0x4B5701D: lws_zalloc (alloc.c:159)
==902== by 0x4B6F719: lws_create_vhost (vhost.c:599)
==902== by 0x6C59C4: example_libwebsockets_lws_vhost_create_callback_helper (example_libwebsockets.c:872)
==902== by 0x6C58BC: example_libwebsockets_lws_vhost_create_callback (example_libwebsockets.c:800)
==902== by 0x6C5597: example_libwebsockets_lws_vhost_init (example_libwebsockets.c:715)
==902== by 0x6C467C: example_libwebsockets_task (example_libwebsockets.c:175)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902==
==902== Invalid read of size 4
==902== at 0x4B833EA: _lws_vhost_init_server (server.c:422)
==902== by 0x4B4C791: lws_sul_plat_unix (unix-init.c:69)
==902== by 0x4B74A76: __lws_sul_service_ripe (sorted-usec-list.c:161)
==902== by 0x4B4D40C: _lws_plat_service_tsi (unix-service.c:125)
==902== by 0x4B4D684: lws_plat_service (unix-service.c:235)
==902== by 0x4B7463F: lws_service (service.c:838)
==902== by 0x6C46D9: example_libwebsockets_task (example_libwebsockets.c:185)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902== Address 0x2c511cc8 is 792 bytes inside a block of size 854 free'd
==902== at 0x4839900: free (vg_replace_malloc.c:540)
==902== by 0x4B56FBB: _realloc (alloc.c:144)
==902== by 0x4B56FF2: lws_realloc (alloc.c:154)
==902== by 0x4B71537: __lws_vhost_destroy2 (vhost.c:1585)
==902== by 0x4B715DF: lws_vhost_destroy (vhost.c:1631)
==902== by 0x6C5B50: example_libwebsockets_lws_vhost_destroy_callback (example_libwebsockets.c:911)
==902== by 0x6C5DC5: example_libwebsockets_callback_event_wait_cancelled (example_libwebsockets.c:1042)
==902== by 0x6C4968: example_libwebsockets_http_callback (example_libwebsockets.c:301)
==902== by 0x4B76876: lws_broadcast (wsi.c:869)
==902== by 0x4B798DC: rops_handle_POLLIN_pipe (ops-pipe.c:111)
==902== by 0x4B7442F: lws_service_fd_tsi (service.c:766)
==902== by 0x4B4D214: _lws_plat_service_forced_tsi (unix-service.c:51)
==902== Block was alloc'd at
==902== at 0x4838694: malloc (vg_replace_malloc.c:308)
==902== by 0x483ABE3: realloc (vg_replace_malloc.c:836)
==902== by 0x4B56F61: _realloc (alloc.c:133)
==902== by 0x4B5701D: lws_zalloc (alloc.c:159)
==902== by 0x4B6F719: lws_create_vhost (vhost.c:599)
==902== by 0x6C59C4: example_libwebsockets_lws_vhost_create_callback_helper (example_libwebsockets.c:872)
==902== by 0x6C58BC: example_libwebsockets_lws_vhost_create_callback (example_libwebsockets.c:800)
==902== by 0x6C5597: example_libwebsockets_lws_vhost_init (example_libwebsockets.c:715)
==902== by 0x6C467C: example_libwebsockets_task (example_libwebsockets.c:175)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902==
==902== Invalid read of size 8
==902== at 0x4B83403: _lws_vhost_init_server (server.c:435)
==902== by 0x4B4C791: lws_sul_plat_unix (unix-init.c:69)
==902== by 0x4B74A76: __lws_sul_service_ripe (sorted-usec-list.c:161)
==902== by 0x4B4D40C: _lws_plat_service_tsi (unix-service.c:125)
==902== by 0x4B4D684: lws_plat_service (unix-service.c:235)
==902== by 0x4B7463F: lws_service (service.c:838)
==902== by 0x6C46D9: example_libwebsockets_task (example_libwebsockets.c:185)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902== Address 0x2c511b68 is 440 bytes inside a block of size 854 free'd
==902== at 0x4839900: free (vg_replace_malloc.c:540)
==902== by 0x4B56FBB: _realloc (alloc.c:144)
==902== by 0x4B56FF2: lws_realloc (alloc.c:154)
==902== by 0x4B71537: __lws_vhost_destroy2 (vhost.c:1585)
==902== by 0x4B715DF: lws_vhost_destroy (vhost.c:1631)
==902== by 0x6C5B50: example_libwebsockets_lws_vhost_destroy_callback (example_libwebsockets.c:911)
==902== by 0x6C5DC5: example_libwebsockets_callback_event_wait_cancelled (example_libwebsockets.c:1042)
==902== by 0x6C4968: example_libwebsockets_http_callback (example_libwebsockets.c:301)
==902== by 0x4B76876: lws_broadcast (wsi.c:869)
==902== by 0x4B798DC: rops_handle_POLLIN_pipe (ops-pipe.c:111)
==902== by 0x4B7442F: lws_service_fd_tsi (service.c:766)
==902== by 0x4B4D214: _lws_plat_service_forced_tsi (unix-service.c:51)
==902== Block was alloc'd at
==902== at 0x4838694: malloc (vg_replace_malloc.c:308)
==902== by 0x483ABE3: realloc (vg_replace_malloc.c:836)
==902== by 0x4B56F61: _realloc (alloc.c:133)
==902== by 0x4B5701D: lws_zalloc (alloc.c:159)
==902== by 0x4B6F719: lws_create_vhost (vhost.c:599)
==902== by 0x6C59C4: example_libwebsockets_lws_vhost_create_callback_helper (example_libwebsockets.c:872)
==902== by 0x6C58BC: example_libwebsockets_lws_vhost_create_callback (example_libwebsockets.c:800)
==902== by 0x6C5597: example_libwebsockets_lws_vhost_init (example_libwebsockets.c:715)
==902== by 0x6C467C: example_libwebsockets_task (example_libwebsockets.c:175)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902==
==902== Invalid read of size 8
==902== at 0x4B83424: _lws_vhost_init_server (server.c:447)
==902== by 0x4B4C791: lws_sul_plat_unix (unix-init.c:69)
==902== by 0x4B74A76: __lws_sul_service_ripe (sorted-usec-list.c:161)
==902== by 0x4B4D40C: _lws_plat_service_tsi (unix-service.c:125)
==902== by 0x4B4D684: lws_plat_service (unix-service.c:235)
==902== by 0x4B7463F: lws_service (service.c:838)
==902== by 0x6C46D9: example_libwebsockets_task (example_libwebsockets.c:185)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902== Address 0x2c511ba8 is 504 bytes inside a block of size 854 free'd
==902== at 0x4839900: free (vg_replace_malloc.c:540)
==902== by 0x4B56FBB: _realloc (alloc.c:144)
==902== by 0x4B56FF2: lws_realloc (alloc.c:154)
==902== by 0x4B71537: __lws_vhost_destroy2 (vhost.c:1585)
==902== by 0x4B715DF: lws_vhost_destroy (vhost.c:1631)
==902== by 0x6C5B50: example_libwebsockets_lws_vhost_destroy_callback (example_libwebsockets.c:911)
==902== by 0x6C5DC5: example_libwebsockets_callback_event_wait_cancelled (example_libwebsockets.c:1042)
==902== by 0x6C4968: example_libwebsockets_http_callback (example_libwebsockets.c:301)
==902== by 0x4B76876: lws_broadcast (wsi.c:869)
==902== by 0x4B798DC: rops_handle_POLLIN_pipe (ops-pipe.c:111)
==902== by 0x4B7442F: lws_service_fd_tsi (service.c:766)
==902== by 0x4B4D214: _lws_plat_service_forced_tsi (unix-service.c:51)
==902== Block was alloc'd at
==902== at 0x4838694: malloc (vg_replace_malloc.c:308)
==902== by 0x483ABE3: realloc (vg_replace_malloc.c:836)
==902== by 0x4B56F61: _realloc (alloc.c:133)
==902== by 0x4B5701D: lws_zalloc (alloc.c:159)
==902== by 0x4B6F719: lws_create_vhost (vhost.c:599)
==902== by 0x6C59C4: example_libwebsockets_lws_vhost_create_callback_helper (example_libwebsockets.c:872)
==902== by 0x6C58BC: example_libwebsockets_lws_vhost_create_callback (example_libwebsockets.c:800)
==902== by 0x6C5597: example_libwebsockets_lws_vhost_init (example_libwebsockets.c:715)
==902== by 0x6C467C: example_libwebsockets_task (example_libwebsockets.c:175)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902==
==902== Invalid read of size 8
==902== at 0x4B82A62: _lws_vhost_init_server_af (server.c:87)
==902== by 0x4B834AB: _lws_vhost_init_server (server.c:482)
==902== by 0x4B4C791: lws_sul_plat_unix (unix-init.c:69)
==902== by 0x4B74A76: __lws_sul_service_ripe (sorted-usec-list.c:161)
==902== by 0x4B4D40C: _lws_plat_service_tsi (unix-service.c:125)
==902== by 0x4B4D684: lws_plat_service (unix-service.c:235)
==902== by 0x4B7463F: lws_service (service.c:838)
==902== by 0x6C46D9: example_libwebsockets_task (example_libwebsockets.c:185)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902== Address 0x2c511b70 is 448 bytes inside a block of size 854 free'd
==902== at 0x4839900: free (vg_replace_malloc.c:540)
==902== by 0x4B56FBB: _realloc (alloc.c:144)
==902== by 0x4B56FF2: lws_realloc (alloc.c:154)
==902== by 0x4B71537: __lws_vhost_destroy2 (vhost.c:1585)
==902== by 0x4B715DF: lws_vhost_destroy (vhost.c:1631)
==902== by 0x6C5B50: example_libwebsockets_lws_vhost_destroy_callback (example_libwebsockets.c:911)
==902== by 0x6C5DC5: example_libwebsockets_callback_event_wait_cancelled (example_libwebsockets.c:1042)
==902== by 0x6C4968: example_libwebsockets_http_callback (example_libwebsockets.c:301)
==902== by 0x4B76876: lws_broadcast (wsi.c:869)
==902== by 0x4B798DC: rops_handle_POLLIN_pipe (ops-pipe.c:111)
==902== by 0x4B7442F: lws_service_fd_tsi (service.c:766)
==902== by 0x4B4D214: _lws_plat_service_forced_tsi (unix-service.c:51)
==902== Block was alloc'd at
==902== at 0x4838694: malloc (vg_replace_malloc.c:308)
==902== by 0x483ABE3: realloc (vg_replace_malloc.c:836)
==902== by 0x4B56F61: _realloc (alloc.c:133)
==902== by 0x4B5701D: lws_zalloc (alloc.c:159)
==902== by 0x4B6F719: lws_create_vhost (vhost.c:599)
==902== by 0x6C59C4: example_libwebsockets_lws_vhost_create_callback_helper (example_libwebsockets.c:872)
==902== by 0x6C58BC: example_libwebsockets_lws_vhost_create_callback (example_libwebsockets.c:800)
==902== by 0x6C5597: example_libwebsockets_lws_vhost_init (example_libwebsockets.c:715)
==902== by 0x6C467C: example_libwebsockets_task (example_libwebsockets.c:175)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902==
==902== Invalid read of size 8
==902== at 0x4B82AB0: _lws_vhost_init_server_af (server.c:102)
==902== by 0x4B834AB: _lws_vhost_init_server (server.c:482)
==902== by 0x4B4C791: lws_sul_plat_unix (unix-init.c:69)
==902== by 0x4B74A76: __lws_sul_service_ripe (sorted-usec-list.c:161)
==902== by 0x4B4D40C: _lws_plat_service_tsi (unix-service.c:125)
==902== by 0x4B4D684: lws_plat_service (unix-service.c:235)
==902== by 0x4B7463F: lws_service (service.c:838)
==902== by 0x6C46D9: example_libwebsockets_task (example_libwebsockets.c:185)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902== Address 0x2c511b70 is 448 bytes inside a block of size 854 free'd
==902== at 0x4839900: free (vg_replace_malloc.c:540)
==902== by 0x4B56FBB: _realloc (alloc.c:144)
==902== by 0x4B56FF2: lws_realloc (alloc.c:154)
==902== by 0x4B71537: __lws_vhost_destroy2 (vhost.c:1585)
==902== by 0x4B715DF: lws_vhost_destroy (vhost.c:1631)
==902== by 0x6C5B50: example_libwebsockets_lws_vhost_destroy_callback (example_libwebsockets.c:911)
==902== by 0x6C5DC5: example_libwebsockets_callback_event_wait_cancelled (example_libwebsockets.c:1042)
==902== by 0x6C4968: example_libwebsockets_http_callback (example_libwebsockets.c:301)
==902== by 0x4B76876: lws_broadcast (wsi.c:869)
==902== by 0x4B798DC: rops_handle_POLLIN_pipe (ops-pipe.c:111)
==902== by 0x4B7442F: lws_service_fd_tsi (service.c:766)
==902== by 0x4B4D214: _lws_plat_service_forced_tsi (unix-service.c:51)
==902== Block was alloc'd at
==902== at 0x4838694: malloc (vg_replace_malloc.c:308)
==902== by 0x483ABE3: realloc (vg_replace_malloc.c:836)
==902== by 0x4B56F61: _realloc (alloc.c:133)
==902== by 0x4B5701D: lws_zalloc (alloc.c:159)
==902== by 0x4B6F719: lws_create_vhost (vhost.c:599)
==902== by 0x6C59C4: example_libwebsockets_lws_vhost_create_callback_helper (example_libwebsockets.c:872)
==902== by 0x6C58BC: example_libwebsockets_lws_vhost_create_callback (example_libwebsockets.c:800)
==902== by 0x6C5597: example_libwebsockets_lws_vhost_init (example_libwebsockets.c:715)
==902== by 0x6C467C: example_libwebsockets_task (example_libwebsockets.c:175)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902==
==902== Invalid read of size 8
==902== at 0x4B70C1D: lws_vhost_foreach_listen_wsi (vhost.c:1262)
==902== by 0x4B82ACC: _lws_vhost_init_server_af (server.c:102)
==902== by 0x4B834AB: _lws_vhost_init_server (server.c:482)
==902== by 0x4B4C791: lws_sul_plat_unix (unix-init.c:69)
==902== by 0x4B74A76: __lws_sul_service_ripe (sorted-usec-list.c:161)
==902== by 0x4B4D40C: _lws_plat_service_tsi (unix-service.c:125)
==902== by 0x4B4D684: lws_plat_service (unix-service.c:235)
==902== by 0x4B7463F: lws_service (service.c:838)
==902== by 0x6C46D9: example_libwebsockets_task (example_libwebsockets.c:185)
==902== by 0x61E16C: _init_task (task.c:75)
==902== by 0x49A2EA3: ??? (in /lib/libpthread-2.31.so)
==902== by 0x51C7DCE: clone (in /lib/libc-2.31.so)
==902== Address 0x628 is not stack'd, malloc'd or (recently) free'd
The output above mentions a function "example_libwebsockets_lws_vhost_destroy_callback" which was not included in the previous issue entry. Here is the definition for it.
/**
* \brief Finds a vhost and destroys it.
*
* \param networking_interface_id Pointer to the id of an interface. This value will take ownership of this pointer/be freed by this function.
*/
static void example_libwebsockets_lws_vhost_destroy_callback(void *param)
{
char vhost_name[IFNAMSIZ];
char *ifname;
struct lws_vhost *vhost = NULL;
int *networking_interface_id = param;
log_printf(example_log, log_priority_internal_debug3, "Removing vhost for interface: id = %d.", *networking_interface_id);
/* Find vhost. */
snprintf(vhost_name, IFNAMSIZ, "%d", *networking_interface_id);
vhost = lws_get_vhost_by_name(example_libwebsockets_lws_context, vhost_name);
if (vhost == NULL) {
log_printf(example_log, log_priority_internal_debug0, "Unable to find vhost name given the networking interface id: %d", *networking_interface_id);
goto bail;
}
/* Destroy the vhost. */
ifname = (char *)lws_get_vhost_iface(vhost); /* Cast so we may free it. This was allocated during creation. */
lws_vhost_destroy(vhost);
mem_free(ifname);
ifname = NULL;
bail:
mem_free(networking_interface_id);
return;
}
Extra note which might be relevant: The interfaces on our platform do update/change every now and then.
Currently when an interface is updated, we ask libwebsockets to remove and re-add the vhost responsible for that interface with updated values. This happens by queuing _example_libwebsockets_lws_vhost_destroycallback() and _example_libwebsockets_lws_vhost_createcallback() and then call _lws_servicecancel(), which then will run them in that same order. Is it a problem that a vhost is removed and re-added within the same LWS_CALLBACK_EVENT_WAIT_CANCELLED event?
Hi, and thank you for your work on this library!
I'm using libwebsockets (version/tag 4.3.2) for my server, and somewhat randomly it crashes with the following stacktrace.
We have tried to debug our code based on the stacktrace above, but we are unable to figure out why the context pointer of the vhost, and the vhost itself is null (seemingly uninitialized) or why it arrives where it does in the first place. We seem to crash at the same place each time, so at least it is consistent.
Below is an example based on our setup/config. I was wondering if there are any obvious issues with our configuration that eventually causes libwebsockets to reach this state?
Libwebsockets starts in "example_libwebsockets_init()".