Skip to content

TSAN: data race in tests/test_ch.c, global variable session_established_flag #602

@jktjkt

Description

@jktjkt

Please use, e.g., an atomic variable for this.

WARNING: ThreadSanitizer: data race (pid=3845)
  Write of size 4 at 0x000001952de0 by thread T9:
    #0 ch_new_session_set_flag_cb /home/ci/src/cesnet-gerrit-public/github/CESNET/libnetconf2/tests/test_ch.c:408:30 (test_ch+0x58b0ae) (BuildId: 5199417ab5ed6ab22fc3ee98039cfa2ce7f6d72d)
    #1 nc_server_ch_client_thread_session_cond_wait /home/ci/src/cesnet-gerrit-public/github/CESNET/libnetconf2/src/session_server.c:3337:9 (test_ch+0x51d0db) (BuildId: 5199417ab5ed6ab22fc3ee98039cfa2ce7f6d72d)
    #2 nc_ch_client_thread /home/ci/src/cesnet-gerrit-public/github/CESNET/libnetconf2/src/session_server.c:3574:17 (test_ch+0x516fe0) (BuildId: 5199417ab5ed6ab22fc3ee98039cfa2ce7f6d72d)

  Previous read of size 4 at 0x000001952de0 by thread T8:
    #0 server_thread_delete_while_session /home/ci/src/cesnet-gerrit-public/github/CESNET/libnetconf2/tests/test_ch.c:433:13 (test_ch+0x58aedd) (BuildId: 5199417ab5ed6ab22fc3ee98039cfa2ce7f6d72d)

  As if synchronized via sleep:
    #0 usleep <null> (test_ch+0x45552b) (BuildId: 5199417ab5ed6ab22fc3ee98039cfa2ce7f6d72d)
    #1 nc_accept_ssh_session_open_netconf_channel /home/ci/src/cesnet-gerrit-public/github/CESNET/libnetconf2/src/session_server_ssh.c:1957:9 (test_ch+0x56b95f) (BuildId: 5199417ab5ed6ab22fc3ee98039cfa2ce7f6d72d)
    #2 nc_accept_ssh_session /home/ci/src/cesnet-gerrit-public/github/CESNET/libnetconf2/src/session_server_ssh.c:2201:15 (test_ch+0x56b104) (BuildId: 5199417ab5ed6ab22fc3ee98039cfa2ce7f6d72d)
    #3 nc_connect_ch_endpt /home/ci/src/cesnet-gerrit-public/github/CESNET/libnetconf2/src/session_server.c:3219:15 (test_ch+0x51cb98) (BuildId: 5199417ab5ed6ab22fc3ee98039cfa2ce7f6d72d)
    #4 nc_ch_client_thread /home/ci/src/cesnet-gerrit-public/github/CESNET/libnetconf2/src/session_server.c:3562:19 (test_ch+0x516ec8) (BuildId: 5199417ab5ed6ab22fc3ee98039cfa2ce7f6d72d)

  Location is global 'session_established_flag' of size 4 at 0x000001952de0 (test_ch+0x1952de0)

  Thread T9 (tid=4052, running) created by thread T8 at:
    #0 pthread_create <null> (test_ch+0x45879f) (BuildId: 5199417ab5ed6ab22fc3ee98039cfa2ce7f6d72d)
    #1 _nc_connect_ch_client_dispatch /home/ci/src/cesnet-gerrit-public/github/CESNET/libnetconf2/src/session_server.c:3825:14 (test_ch+0x516b4b) (BuildId: 5199417ab5ed6ab22fc3ee98039cfa2ce7f6d72d)
    #2 nc_connect_ch_client_dispatch /home/ci/src/cesnet-gerrit-public/github/CESNET/libnetconf2/src/session_server.c:3867:10 (test_ch+0x5181c1) (BuildId: 5199417ab5ed6ab22fc3ee98039cfa2ce7f6d72d)
    #3 server_thread_delete_while_session /home/ci/src/cesnet-gerrit-public/github/CESNET/libnetconf2/tests/test_ch.c:429:11 (test_ch+0x58aeaf) (BuildId: 5199417ab5ed6ab22fc3ee98039cfa2ce7f6d72d)

  Thread T8 (tid=4051, running) created by main thread at:
    #0 pthread_create <null> (test_ch+0x45879f) (BuildId: 5199417ab5ed6ab22fc3ee98039cfa2ce7f6d72d)
    #1 test_nc_ch_delete_client_while_session /home/ci/src/cesnet-gerrit-public/github/CESNET/libnetconf2/tests/test_ch.c:553:11 (test_ch+0x589527) (BuildId: 5199417ab5ed6ab22fc3ee98039cfa2ce7f6d72d)
    #2 <null> <null> (libcmocka.so.0+0x618f) (BuildId: 785844a0941c0bde763740a981d056f60aa9c7b7)
    #3 __libc_start_call_main /usr/src/debug/glibc-2.37-18.fc38.x86_64/csu/../sysdeps/nptl/libc_start_call_main.h:58:16 (libc.so.6+0x27b89) (BuildId: 70e92bb237883be3065a6afc9f0696aef2d068bf)

SUMMARY: ThreadSanitizer: data race /home/ci/src/cesnet-gerrit-public/github/CESNET/libnetconf2/tests/test_ch.c:408:30 in ch_new_session_set_flag_cb

Metadata

Metadata

Assignees

No one assigned

    Labels

    is:bugBug description.status:completedFrom the developer perspective, the issue was solved (bug fixed, question answered,...)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions