Skip to content

"Invalid write" in socket_consume_mailbox / sys_unregister_listener / sys_register_listener #2155

Description

@bettio

Valgrind detected "Invalid write of size 8" in main branch (0fb092b) here:
https://github.com/atomvm/AtomVM/actions/runs/22663342356/job/65688810253

Relevant log

WARNING: EAI_SERVICE unsupported on this platform.
WARNING: EAI_SERVICE unsupported on this platform.
WARNING: EAI_SERVICE unsupported on this platform.
WARNING: EAI_SERVICE unsupported on this platform.
WARNING: EAI_SERVICE unsupported on this platform.
++++++++++++++GEN_UDP-TEST> SpawnControllingProcess=false IsActive=false Mode=binary Backendoption=[{inet_backend,inet}]
GEN_UDP-TEST> SpawnControllingProcess=false IsActive=false Mode=binary Backendoption=[{inet_backend,socket}]
GEN_UDP-TEST> SpawnControllingProcess=false IsActive=false Mode=list Backendoption=[{inet_backend,inet}]
GEN_UDP-TEST> SpawnControllingProcess=false IsActive=false Mode=list Backendoption=[{inet_backend,socket}]
GEN_UDP-TEST> SpawnControllingProcess=false IsActive=true Mode=binary Backendoption=[{inet_backend,inet}]
GEN_UDP-TEST> SpawnControllingProcess=false IsActive=true Mode=binary Backendoption=[{inet_backend,socket}]
GEN_UDP-TEST> SpawnControllingProcess=false IsActive=true Mode=list Backendoption=[{inet_backend,inet}]
GEN_UDP-TEST> SpawnControllingProcess=false IsActive=true Mode=list Backendoption=[{inet_backend,socket}]
GEN_UDP-TEST> SpawnControllingProcess=true IsActive=false Mode=binary Backendoption=[{inet_backend,inet}]
GEN_UDP-TEST> SpawnControllingProcess=true IsActive=false Mode=binary Backendoption=[{inet_backend,socket}]
GEN_UDP-TEST> SpawnControllingProcess=true IsActive=false Mode=list Backendoption=[{inet_backend,inet}]
GEN_UDP-TEST> SpawnControllingProcess=true IsActive=false Mode=list Backendoption=[{inet_backend,socket}]
GEN_UDP-TEST> SpawnControllingProcess=true IsActive=true Mode=binary Backendoption=[{inet_backend,inet}]
GEN_UDP-TEST> SpawnControllingProcess=true IsActive=true Mode=binary Backendoption=[{inet_backend,socket}]
GEN_UDP-TEST> SpawnControllingProcess=true IsActive=true Mode=list Backendoption=[{inet_backend,inet}]
GEN_UDP-TEST> SpawnControllingProcess=true IsActive=true Mode=list Backendoption=[{inet_backend,socket}]
+GEN_TCP-TEST> ServerBackendOption=[{inet_backend,socket}] ClientBackendOption=[{inet_backend,socket}] ListenMode=binary ConnectMode=binary ListenActive=false ConnectActive=false
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,socket}] ClientBackendOption=[{inet_backend,socket}] ListenMode=binary ConnectMode=binary ListenActive=false ConnectActive=true
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,socket}] ClientBackendOption=[{inet_backend,socket}] ListenMode=binary ConnectMode=binary ListenActive=true ConnectActive=false
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,socket}] ClientBackendOption=[{inet_backend,socket}] ListenMode=binary ConnectMode=binary ListenActive=true ConnectActive=true
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,socket}] ClientBackendOption=[{inet_backend,socket}] ListenMode=binary ConnectMode=list ListenActive=false ConnectActive=false
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,socket}] ClientBackendOption=[{inet_backend,socket}] ListenMode=binary ConnectMode=list ListenActive=false ConnectActive=true
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,socket}] ClientBackendOption=[{inet_backend,socket}] ListenMode=binary ConnectMode=list ListenActive=true ConnectActive=false
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,socket}] ClientBackendOption=[{inet_backend,socket}] ListenMode=binary ConnectMode=list ListenActive=true ConnectActive=true
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,socket}] ClientBackendOption=[{inet_backend,socket}] ListenMode=list ConnectMode=binary ListenActive=false ConnectActive=false
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,socket}] ClientBackendOption=[{inet_backend,socket}] ListenMode=list ConnectMode=binary ListenActive=false ConnectActive=true
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,socket}] ClientBackendOption=[{inet_backend,socket}] ListenMode=list ConnectMode=binary ListenActive=true ConnectActive=false
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,socket}] ClientBackendOption=[{inet_backend,socket}] ListenMode=list ConnectMode=binary ListenActive=true ConnectActive=true
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,socket}] ClientBackendOption=[{inet_backend,socket}] ListenMode=list ConnectMode=list ListenActive=false ConnectActive=false
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,socket}] ClientBackendOption=[{inet_backend,socket}] ListenMode=list ConnectMode=list ListenActive=false ConnectActive=true
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,socket}] ClientBackendOption=[{inet_backend,socket}] ListenMode=list ConnectMode=list ListenActive=true ConnectActive=false
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,socket}] ClientBackendOption=[{inet_backend,socket}] ListenMode=list ConnectMode=list ListenActive=true ConnectActive=true
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,inet}] ClientBackendOption=[{inet_backend,inet}] ListenMode=binary ConnectMode=binary ListenActive=false ConnectActive=false
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,inet}] ClientBackendOption=[{inet_backend,inet}] ListenMode=binary ConnectMode=binary ListenActive=false ConnectActive=true
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,inet}] ClientBackendOption=[{inet_backend,inet}] ListenMode=binary ConnectMode=binary ListenActive=true ConnectActive=false
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,inet}] ClientBackendOption=[{inet_backend,inet}] ListenMode=binary ConnectMode=binary ListenActive=true ConnectActive=true
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,inet}] ClientBackendOption=[{inet_backend,inet}] ListenMode=binary ConnectMode=list ListenActive=false ConnectActive=false
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,inet}] ClientBackendOption=[{inet_backend,inet}] ListenMode=binary ConnectMode=list ListenActive=false ConnectActive=true
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,inet}] ClientBackendOption=[{inet_backend,inet}] ListenMode=binary ConnectMode=list ListenActive=true ConnectActive=false
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,inet}] ClientBackendOption=[{inet_backend,inet}] ListenMode=binary ConnectMode=list ListenActive=true ConnectActive=true
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,inet}] ClientBackendOption=[{inet_backend,inet}] ListenMode=list ConnectMode=binary ListenActive=false ConnectActive=false
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,inet}] ClientBackendOption=[{inet_backend,inet}] ListenMode=list ConnectMode=binary ListenActive=false ConnectActive=true
==22213== Thread 3:
==22213== Invalid write of size 8
==22213==    at 0x2527F5: list_remove (list.h:76)
==22213==    by 0x2528BF: synclist_remove (synclist.h:105)
==22213==    by 0x253AE2: sys_unregister_listener (sys.c:698)
==22213==    by 0x2644E0: socket_consume_mailbox (socket_driver.c:1219)
==22213==    by 0x194DAA: scheduler_run (scheduler.c:296)
==22213==    by 0x194634: scheduler_wait (scheduler.c:76)
==22213==    by 0x1B531A: scheduler_entry_point (opcodesswitch.h:2964)
==22213==    by 0x2522F6: scheduler_thread_entry_point (smp.c:75)
==22213==    by 0x4A5B608: start_thread (pthread_create.c:477)
==22213==    by 0x4B95352: clone (clone.S:95)
==22213==  Address 0x9597780 is 0 bytes inside a block of size 48 free'd
==22213==    at 0x483CA3F: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==22213==    by 0x2644C3: socket_consume_mailbox (socket_driver.c:1216)
==22213==    by 0x194DAA: scheduler_run (scheduler.c:296)
==22213==    by 0x194634: scheduler_wait (scheduler.c:76)
==22213==    by 0x1B531A: scheduler_entry_point (opcodesswitch.h:2964)
==22213==    by 0x1AA035: context_execute_loop (opcodesswitch.h:1992)
==22213==    by 0x1222DC: globalcontext_run (globalcontext.c:783)
==22213==    by 0x11E131: main (main.c:266)
==22213==  Block was alloc'd at
==22213==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==22213==    by 0x2613EE: init_client_tcp_socket (socket_driver.c:332)
==22213==    by 0x261A41: socket_driver_do_init (socket_driver.c:483)
==22213==    by 0x264101: socket_consume_mailbox (socket_driver.c:1160)
==22213==    by 0x194DAA: scheduler_run (scheduler.c:296)
==22213==    by 0x194634: scheduler_wait (scheduler.c:76)
==22213==    by 0x1B531A: scheduler_entry_point (opcodesswitch.h:2964)
==22213==    by 0x2522F6: scheduler_thread_entry_point (smp.c:75)
==22213==    by 0x4A5B608: start_thread (pthread_create.c:477)
==22213==    by 0x4B95352: clone (clone.S:95)
==22213== 
GEN_TCP-TEST> ServerBackendOption=[{inet_backend,inet}] ClientBackendOption=[{inet_backend,inet}] ListenMode=list ConnectMode=binary ListenActive=true ConnectActive=false
==22213== Thread 1:
==22213== Invalid write of size 8
==22213==    at 0x2527AA: list_insert (list.h:61)
==22213==    by 0x2527DA: list_append (list.h:66)
==22213==    by 0x253A29: sys_register_listener (sys.c:673)
==22213==    by 0x263ED5: socket_driver_do_accept (socket_driver.c:1120)
==22213==    by 0x2643E1: socket_consume_mailbox (socket_driver.c:1192)
==22213==    by 0x194DAA: scheduler_run (scheduler.c:296)
==22213==    by 0x194634: scheduler_wait (scheduler.c:76)
==22213==    by 0x1B531A: scheduler_entry_point (opcodesswitch.h:2964)
==22213==    by 0x1AA035: context_execute_loop (opcodesswitch.h:1992)
==22213==    by 0x1222DC: globalcontext_run (globalcontext.c:783)
==22213==    by 0x11E131: main (main.c:266)
==22213==  Address 0x9597780 is 0 bytes inside a block of size 48 free'd
==22213==    at 0x483CA3F: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==22213==    by 0x2644C3: socket_consume_mailbox (socket_driver.c:1216)
==22213==    by 0x194DAA: scheduler_run (scheduler.c:296)
==22213==    by 0x194634: scheduler_wait (scheduler.c:76)
==22213==    by 0x1B531A: scheduler_entry_point (opcodesswitch.h:2964)
==22213==    by 0x1AA035: context_execute_loop (opcodesswitch.h:1992)
==22213==    by 0x1222DC: globalcontext_run (globalcontext.c:783)
==22213==    by 0x11E131: main (main.c:266)
==22213==  Block was alloc'd at
==22213==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==22213==    by 0x2613EE: init_client_tcp_socket (socket_driver.c:332)
==22213==    by 0x261A41: socket_driver_do_init (socket_driver.c:483)
==22213==    by 0x264101: socket_consume_mailbox (socket_driver.c:1160)
==22213==    by 0x194DAA: scheduler_run (scheduler.c:296)
==22213==    by 0x194634: scheduler_wait (scheduler.c:76)
==22213==    by 0x1B531A: scheduler_entry_point (opcodesswitch.h:2964)
==22213==    by 0x2522F6: scheduler_thread_entry_point (smp.c:75)
==22213==    by 0x4A5B608: start_thread (pthread_create.c:477)
==22213==    by 0x4B95352: clone (clone.S:95)
==22213== 
context canceled

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions