[
https://issues.apache.org/jira/browse/DISPATCH-2314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17481011#comment-17481011
]
Jiri Daněk commented on DISPATCH-2314:
--------------------------------------
As [~kgiusti] said, this happens when the flag gets operated upon from two
different threads, one running {{qdr_delivery_continue_CT}} and the other one
{{qdr_delivery_set_presettled}}.
What the warning means is that the update to the flag happening in the second
function may or may not be visible in the first, because the happens-before
relationship between the threads respective actions has not been established.
Another important function of thread synchronization is publishing: so that
updates that happen in one thread become visible to the other threads; this is
not of much concert on x86-64 (which is cache-coherent, so the change in flag
becomes visible the moment it leaves CPU registers), but is more significant on
other architectures. We do not have to worry about atomicity, (update being
only partially visible to the other threads) because updating a bool is always
atomic anyways.
The important question obviously is, "does it have any impact on
functionality?" and also "is it brittle in a way such is likely to have
negative impact later?". I think the latter is true; having two threads, one
concerned with sending, and other with receiving, operating on the same data at
the same time, without synchronization, seems to me risky and hard to reason
about regarding future modifications of the codebase.
> TSAN data race when setting the presettled flag
> -----------------------------------------------
>
> Key: DISPATCH-2314
> URL: https://issues.apache.org/jira/browse/DISPATCH-2314
> Project: Qpid Dispatch
> Issue Type: Bug
> Components: Container
> Reporter: Ganesh Murthy
> Priority: Major
>
> {noformat}
> 21: E Process 2380 error: exit code 66, expected 0
> 21: E qdrouterd -c test-router.conf -I
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/python
> 21: E
> /__w/qpid-dispatch/qpid-dispatch/qpid-dispatch/build/tests/system_test.dir/system_tests_one_router/OneRouterTest/setUpClass/test-router-9.cmd
> 21: E >>>>
> 21: E ==================
> 21: E WARNING: ThreadSanitizer: data race (pid=2380)
> 21: E Write of size 1 at 0x7b440003d355 by thread T4:
> 21: E #0 qdr_delivery_set_presettled
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/router_core/delivery.c:136
> (qdrouterd+0x49d8c5)
> 21: E #1 AMQP_rx_handler
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/router_node.c:538
> (qdrouterd+0x4d2ff5)
> 21: E #2 deferred_AMQP_rx_handler
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/router_node.c:922
> (qdrouterd+0x4d37b2)
> 21: E #3 invoke_deferred_calls
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/server.c:801
> (qdrouterd+0x4d584b)
> 21: E #4 invoke_deferred_calls
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/server.c:790
> (qdrouterd+0x4d8b16)
> 21: E #5 handle
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/server.c:1058
> (qdrouterd+0x4d8b16)
> 21: E #6 thread_run
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/server.c:1133
> (qdrouterd+0x4dae84)
> 21: E #7 _thread_init
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/posix/threading.c:172
> (qdrouterd+0x48160d)
> 21: E
> 21: E Previous read of size 1 at 0x7b440003d355 by thread T1:
> 21: E #0 qdr_delivery_continue_CT
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/router_core/delivery.c:1108
> (qdrouterd+0x49f9e2)
> 21: E #1 router_core_thread
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/router_core/router_core_thread.c:236
> (qdrouterd+0x4b572a)
> 21: E #2 _thread_init
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/posix/threading.c:172
> (qdrouterd+0x48160d)
> 21: E
> 21: E Location is heap block of size 320 at 0x7b440003d2c0
> allocated by thread T3:
> 21: E #0 posix_memalign <null> (libtsan.so.0+0x32a23)
> 21: E #1 qd_alloc
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/alloc_pool.c:391
> (qdrouterd+0x44ad29)
> 21: E #2 new_qdr_delivery_t
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/router_core/delivery.c:24
> (qdrouterd+0x49d33c)
> 21: E #3 qdr_link_deliver
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/router_core/transfer.c:64
> (qdrouterd+0x4bb125)
> 21: E #4 AMQP_rx_handler
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/router_node.c:877
> (qdrouterd+0x4d3106)
> 21: E #5 do_receive
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/container.c:219
> (qdrouterd+0x45f234)
> 21: E #6 qd_container_handle_event
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/container.c:734
> (qdrouterd+0x45f234)
> 21: E #7 handle
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/server.c:1108
> (qdrouterd+0x4d8b41)
> 21: E #8 thread_run
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/server.c:1133
> (qdrouterd+0x4dae84)
> 21: E #9 _thread_init
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/posix/threading.c:172
> (qdrouterd+0x48160d)
> 21: E
> 21: E Thread T4 (tid=2385, running) created by main thread at:
> 21: E #0 pthread_create <null> (libtsan.so.0+0x5bef5)
> 21: E #1 sys_thread
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/posix/threading.c:181
> (qdrouterd+0x481a9c)
> 21: E #2 qd_server_run
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/server.c:1525
> (qdrouterd+0x4dba3c)
> 21: E #3 main_process
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/router/src/main.c:115
> (qdrouterd+0x426e5c)
> 21: E #4 main
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/router/src/main.c:369
> (qdrouterd+0x42626c)
> 21: E
> 21: E Thread T1 (tid=2382, running) created by main thread at:
> 21: E #0 pthread_create <null> (libtsan.so.0+0x5bef5)
> 21: E #1 sys_thread
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/posix/threading.c:181
> (qdrouterd+0x481a9c)
> 21: E #2 qdr_core
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/router_core/router_core.c:124
> (qdrouterd+0x4af670)
> 21: E #3 qd_router_setup_late
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/router_node.c:2127
> (qdrouterd+0x4d3f18)
> 21: E #4 ffi_call_unix64 <null> (libffi.so.6+0x6c03)
> 21: E #5 main_process
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/router/src/main.c:97
> (qdrouterd+0x426dfc)
> 21: E #6 main
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/router/src/main.c:369
> (qdrouterd+0x42626c)
> 21: E
> 21: E Thread T3 (tid=2384, running) created by main thread at:
> 21: E #0 pthread_create <null> (libtsan.so.0+0x5bef5)
> 21: E #1 sys_thread
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/posix/threading.c:181
> (qdrouterd+0x481a9c)
> 21: E #2 qd_server_run
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/server.c:1525
> (qdrouterd+0x4dba3c)
> 21: E #3 main_process
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/router/src/main.c:115
> (qdrouterd+0x426e5c)
> 21: E #4 main
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/router/src/main.c:369
> (qdrouterd+0x42626c)
> 21: E
> 21: E SUMMARY: ThreadSanitizer: data race
> /home/runner/work/qpid-dispatch/qpid-dispatch/qpid-dispatch/src/router_core/delivery.c:136
> in qdr_delivery_set_presettled
> 21: E ==================
> 21: E ThreadSanitizer: reported 1 warnings {noformat}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]