<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/54768>54768</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            ThreadSanitizer reports a data race in lldb-vscode
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            lldb
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          JDevlieghere
      </td>
    </tr>
</table>

<pre>
    `VSCode/TestOptions.test` fails when running under TSan

```
******************** TEST 'lldb-shell :: VSCode/TestOptions.test' FAILED ********************
Script:
--
: 'RUN: at line 1';   /Users/jonas/llvm/build-tsan/bin/lldb-vscode --help | /Users/jonas/llvm/build-tsan/bin/FileCheck /Users/jonas/llvm/llvm-project/lldb/test/Shell/VSCode/TestOptions.test
--
Exit Code: 134

Command Output (stderr):
--
==================
WARNING: ThreadSanitizer: data race (pid=37782)
  Write of size 1 at 0x000100b91960 by main thread:
    #0 lldb_vscode::ProgressEventReporter::~ProgressEventReporter() ProgressEvent.cpp:190 (lldb-vscode:arm64+0x10002c5cc)
    #1 lldb_vscode::ProgressEventReporter::~ProgressEventReporter() ProgressEvent.cpp:189 (lldb-vscode:arm64+0x10002c724)
    #2 lldb_vscode::VSCode::~VSCode() VSCode.cpp:61 (lldb-vscode:arm64+0x100031d04)
    #3 lldb_vscode::VSCode::~VSCode() VSCode.cpp:61 (lldb-vscode:arm64+0x10003110c)
    #4 cxa_at_exit_wrapper(void*) <null>:20144608 (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x4c908)

  Previous read of size 1 at 0x000100b91960 by thread T1:
    #0 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, lldb_vscode::ProgressEventReporter::ProgressEventReporter(std::__1::function<void (lldb_vscode::ProgressEvent&)>)::$_0> >(void*) thread:298 (lldb-vscode:arm64+0x10002d62c)

  Location is global 'lldb_vscode::g_vsc' at 0x000100b916d0 (lldb-vscode+0x1000a5960)

  Thread T1 (tid=5495172, running) created by main thread at:
    #0 pthread_create <null>:20144608 (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x2fe20)
    #1 lldb_vscode::ProgressEventReporter::ProgressEventReporter(std::__1::function<void (lldb_vscode::ProgressEvent&)>) ProgressEvent.cpp:181 (lldb-vscode:arm64+0x10002c500)
    #2 lldb_vscode::ProgressEventReporter::ProgressEventReporter(std::__1::function<void (lldb_vscode::ProgressEvent&)>) ProgressEvent.cpp:179 (lldb-vscode:arm64+0x10002c590)
    #3 lldb_vscode::VSCode::VSCode() VSCode.cpp:44 (lldb-vscode:arm64+0x100031918)
    #4 _GLOBAL__sub_I_VSCode.cpp VSCode.cpp (lldb-vscode:arm64+0x10003604c)
    #5 invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const <null>:20144608 (dyld:arm64e+0x15d8c)

SUMMARY: ThreadSanitizer: data race ProgressEvent.cpp:190 in lldb_vscode::ProgressEventReporter::~ProgressEventReporter()
==================
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNV9-P2jgQ_mvCiwVynB8kDzywLFR72m6rhb3qniIndsA9k-Rsh7L962-cEMpu4Lh229NJFo4zGc8342_GQ1qy54kT4t-Xs5JxhyxWXJsPlRFloUcGnkGGciqkRl82vECqLgpRrFFdMK7QakkLB986eHr4DfFhtEvy4wOt5ssVcshYSpYO9YZLiRxvCgNdxkrGaDG9u5_foreYbsEvMyUqY002y-Hw4BMAADuPTw_2iRokRcGRC68c7wYhkC2eNFca5s9lQe0s5W4LU1oLyYZGQ8hgIYpGAr7tdAbuoOEQfKyQM5593x4LIflsw7M__0HNTsNKlZ95Zg5mYWpDtlja2MJ8OawvAjDfC4OaL8F_1_NPz39Wbre0YOhDbaraAKBIG-CJckh8JpC3PzIa3U_Tx4e7h3cWwWqjOGXAQ2HEV67sK0YNR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