Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-4774

Fix data race in `mongoc_cursor_get_host`

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 1.25.2
    • Affects Version/s: None
    • Component/s: None
    • None

      Fix observed data race on /Client/get_description/pooled. Here is the Evergreen task with logs:

          [2023/10/30 20:40:53.295] ==================
          [2023/10/30 20:40:53.295] WARNING: ThreadSanitizer: data race (pid=93753)
          [2023/10/30 20:40:53.295]   Write of size 8 at 0x7b7400020808 by thread T13:
          [2023/10/30 20:40:53.295]     #0 free <null> (test-libmongoc+0x427318)
          [2023/10/30 20:40:53.295]     #1 bson_free /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libbson/src/bson/bson-memory.c:346:4 (test-libmongoc+0x7b8af6)
          [2023/10/30 20:40:53.295]     #2 mongoc_server_description_destroy /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/src/mongoc/mongoc-server-description.c:182:4 (test-libmongoc+0x74fe9a)
          [2023/10/30 20:40:53.295]     #3 _mongoc_topology_server_dtor /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/src/mongoc/mongoc-topology-description.c:58:4 (test-libmongoc+0x7631c9)
          [2023/10/30 20:40:53.295]     #4 mongoc_set_destroy /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/src/mongoc/mongoc-set.c:143:10 (test-libmongoc+0x757b87)
          [2023/10/30 20:40:53.295]     #5 mongoc_topology_description_cleanup /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/src/mongoc/mongoc-topology-description.c:226:7 (test-libmongoc+0x7636ad)
          [2023/10/30 20:40:53.295]     #6 mongoc_topology_description_destroy /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/src/mongoc/mongoc-topology-description.c:263:4 (test-libmongoc+0x7636ad)
          [2023/10/30 20:40:53.295]     #7 _tpld_destroy_and_free /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/src/mongoc/mongoc-topology.c:262:4 (test-libmongoc+0x75f6e9)
          [2023/10/30 20:40:53.295]     #8 _release_aux /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/src/mongoc/mongoc-shared.c:31:4 (test-libmongoc+0x75819b)
          [2023/10/30 20:40:53.295]     #9 mongoc_shared_ptr_reset_null /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/src/mongoc/mongoc-shared.c:141:7 (test-libmongoc+0x75819b)
          [2023/10/30 20:40:53.295]     #10 mc_tpld_modify_commit /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/src/mongoc/mongoc-topology.c:2068:4 (test-libmongoc+0x7600ca)
          [2023/10/30 20:40:53.295]     #11 _update_topology_description /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/src/mongoc/mongoc-server-monitor.c:905:4 (test-libmongoc+0x792cef)
          [2023/10/30 20:40:53.295]     #12 _server_monitor_thread /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/src/mongoc/mongoc-server-monitor.c:1280:7 (test-libmongoc+0x792cef)
          [2023/10/30 20:40:53.295]   Previous read of size 8 at 0x7b7400020808 by main thread:
          [2023/10/30 20:40:53.295]     #0 memcpy <null> (test-libmongoc+0x432387)
          [2023/10/30 20:40:53.295]     #1 mongoc_cursor_get_host /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/src/mongoc/mongoc-cursor.c:1378:25 (test-libmongoc+0x72c682)
          [2023/10/30 20:40:53.295]     #2 _test_mongoc_client_get_description /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/tests/test-mongoc-client.c:2484:4 (test-libmongoc+0x588f50)
          [2023/10/30 20:40:53.295]     #3 test_mongoc_client_get_description_pooled /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/tests/test-mongoc-client.c:2511:4 (test-libmongoc+0x584da6)
          [2023/10/30 20:40:53.295]     #4 TestSuite_AddHelper /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/tests/TestSuite.c:261:4 (test-libmongoc+0x68fe0b)
          [2023/10/30 20:40:53.295]     #5 TestSuite_RunTest /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/tests/TestSuite.c:648:7 (test-libmongoc+0x690c34)
          [2023/10/30 20:40:53.295]     #6 TestSuite_RunAll /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/tests/TestSuite.c:1094:20 (test-libmongoc+0x690c34)
          [2023/10/30 20:40:53.295]     #7 TestSuite_Run /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/tests/TestSuite.c:1139:19 (test-libmongoc+0x690c34)
          [2023/10/30 20:40:53.295]     #8 main /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/tests/test-libmongoc-main.c:157:10 (test-libmongoc+0x4b5802)
          [2023/10/30 20:40:53.295]   Thread T13 (tid=94161, running) created by thread T11 at:
          [2023/10/30 20:40:53.295]     #0 pthread_create <null> (test-libmongoc+0x42858b)
          [2023/10/30 20:40:53.296]     #1 _mongoc_mcommon_thread_create /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/common/common-thread.c:30:11 (test-libmongoc+0x77d615)
          [2023/10/30 20:40:53.296]     #2 mongoc_server_monitor_run /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/src/mongoc/mongoc-server-monitor.c:1410:17 (test-libmongoc+0x79200e)
          [2023/10/30 20:40:53.296]     #3 _background_monitor_reconcile_server_monitor /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/src/mongoc/mongoc-topology-background-monitoring.c:103:7 (test-libmongoc+0x762436)
          [2023/10/30 20:40:53.296]     #4 _mongoc_topology_background_monitoring_reconcile /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/src/mongoc/mongoc-topology-background-monitoring.c:247:7 (test-libmongoc+0x762436)
          [2023/10/30 20:40:53.296]     #5 _update_topology_description /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/src/mongoc/mongoc-server-monitor.c:902:4 (test-libmongoc+0x792cca)
          [2023/10/30 20:40:53.296]     #6 _server_monitor_thread /data/mci/bacbc8b3414b8d8d690d89f321a3342b/mongoc/src/libmongoc/src/mongoc/mongoc-server-monitor.c:1280:7 (test-libmongoc+0x792cca)
          [2023/10/30 20:40:53.296] SUMMARY: ThreadSanitizer: data race (/data/mci/640d11d511f00eaf17ce4d7e56d38655/mongoc/src/libmongoc/test-libmongoc+0x427318) in free
          

            Assignee:
            kevin.albertson@mongodb.com Kevin Albertson
            Reporter:
            kevin.albertson@mongodb.com Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: