This is with commit e08ed5e, but I don't see any relevant commit on top of that, and it doesn't happen every time. In Netopeer2's test_subscribe_param, ntf_status is accessed concurrently without proper locking:
WARNING: ThreadSanitizer: data race (pid=384529)
Read of size 4 at 0x7b4800030508 by thread T5:
#0 nc_ps_poll_session_io libnetconf2/src/session_server.c:1508:74 (libnetconf2.so.3+0x25a69)
#1 nc_ps_poll libnetconf2/src/session_server.c:1705:31 (libnetconf2.so.3+0x25a69)
#2 worker_thread Netopeer2/src/main.c:943:14 (netopeer2-server+0x503096)
Previous write of size 4 at 0x7b4800030508 by thread T7:
#0 nc_session_dec_notif_status libnetconf2/src/session_server.c:3703:9 (libnetconf2.so.3+0x2a9b8)
#1 np2srv_rpc_subscribe_ntf_cb Netopeer2/src/netconf.c:993:9 (netopeer2-server+0x4e9fa4)
#2 sr_notif_call_callback sysrepo/src/common.c:1349:9 (libsysrepo.so.7+0x1f9f0)
#3 sr_subscr_notif_sub_del sysrepo/src/common.c:522:33 (libsysrepo.so.7+0x1f9f0)
#4 sr_notif_sub_del sysrepo/src/common.c:1011:5 (libsysrepo.so.7+0x22645)
#5 sr_subscr_del sysrepo/src/common.c:1227:37 (libsysrepo.so.7+0x2325a)
#6 sr_shmsub_notif_listen_module_stop_time sysrepo/src/shm_sub.c:3667:29 (libsysrepo.so.7+0x659cb)
#7 sr_subscription_process_events sysrepo/src/sysrepo.c:4042:25 (libsysrepo.so.7+0x15758)
#8 sr_shmsub_listen_thread sysrepo/src/shm_sub.c:3752:15 (libsysrepo.so.7+0x65fa5)
As if synchronized via sleep:
#0 usleep <null> (netopeer2-server+0x466bd3)
#1 nc_ps_poll libnetconf2/src/session_server.c:1770:13 (libnetconf2.so.3+0x25cd9)
#2 worker_thread Netopeer2/src/main.c:943:14 (netopeer2-server+0x503096)
Location is heap block of size 344 at 0x7b4800030480 allocated by thread T6:
#0 calloc <null> (netopeer2-server+0x439087)
#1 nc_new_session libnetconf2/src/session.c:184:12 (libnetconf2.so.3+0x15d61)
#2 nc_accept libnetconf2/src/session_server.c:2459:16 (libnetconf2.so.3+0x27ba5)
#3 server_accept_session Netopeer2/src/main.c:910:15 (netopeer2-server+0x503025)
#4 worker_thread Netopeer2/src/main.c:940:9 (netopeer2-server+0x503025)
Thread T5 (tid=384635, running) created by main thread at:
#0 pthread_create <null> (netopeer2-server+0x471c6a)
#1 main Netopeer2/src/main.c:1289:9 (netopeer2-server+0x501618)
Thread T7 (tid=384798, running) created by thread T1 at:
#0 pthread_create <null> (netopeer2-server+0x471c6a)
#1 sr_subscr_new sysrepo/src/sysrepo.c:4580:15 (libsysrepo.so.7+0x16ec2)
#2 _sr_notif_subscribe sysrepo/src/sysrepo.c:5693:25 (libsysrepo.so.7+0x1ad68)
#3 sr_notif_subscribe_tree sysrepo/src/sysrepo.c:5779:12 (libsysrepo.so.7+0x1b10c)
#4 np2srv_rpc_subscribe_cb Netopeer2/src/netconf.c:1144:18 (netopeer2-server+0x4e9bf5)
#5 sr_shmsub_rpc_listen_call_callback sysrepo/src/shm_sub.c:3031:21 (libsysrepo.so.7+0x646e1)
#6 sr_shmsub_rpc_listen_process_rpc_events sysrepo/src/shm_sub.c:3316:25 (libsysrepo.so.7+0x63b26)
#7 sr_subscription_process_events sysrepo/src/sysrepo.c:4027:25 (libsysrepo.so.7+0x15655)
#8 sr_shmsub_listen_thread sysrepo/src/shm_sub.c:3752:15 (libsysrepo.so.7+0x65fa5)
Thread T6 (tid=384637, running) created by main thread at:
#0 pthread_create <null> (netopeer2-server+0x471c6a)
#1 main Netopeer2/src/main.c:1289:9 (netopeer2-server+0x501649)
SUMMARY: ThreadSanitizer: data race libnetconf2/src/session_server.c:1508:74 in n
Also, the code looks fishy in general (why is it checking for session->opts.server.ntf_status beaing non-zero and only decrementing afterwards?). I don't know how the code is using that struct, but It should be either converted to standard atomic variables (if the rest is properly locked), or guarded by a lock.
This is with commit e08ed5e, but I don't see any relevant commit on top of that, and it doesn't happen every time. In Netopeer2's
test_subscribe_param,ntf_statusis accessed concurrently without proper locking:Also, the code looks fishy in general (why is it checking for
session->opts.server.ntf_statusbeaing non-zero and only decrementing afterwards?). I don't know how the code is using thatstruct, but It should be either converted to standard atomic variables (if the rest is properly locked), or guarded by a lock.