Skip to content

Data race on the shared write BIO of DTLS listener connections #33193

Description

@bob-beck

While getting rid of excess stuff in tests, one thing I attempted
was to get rid of the duplicated runs of the multithread tests,
and just use tsan over the multithread test itself.

That resulted in failures.

Found by ThreadSanitizer running test_dtls_multithread. The
threads_sanitizer CI job runs only the listener race tests from that
program, so CI has not caught it.

  • Every connection from a DTLS listener gets the listener's
    dl->net_wbio as its wbio (ssl/d1_lib.c:1358-1370).
  • ssl_init_wbio_buffer() and ssl_free_wbio_buffer() call BIO_push()
    and BIO_pop() on that wbio for each handshake.
  • Both write the shared BIO's prev_bio (crypto/bio/bio_lib.c:783
    and :803) without locking, so concurrent handshakes race.

TSan report:

WARNING: ThreadSanitizer: data race
  Write of size 8 by thread T2:
    #0 BIO_push crypto/bio/bio_lib.c:783
    #1 ssl_init_wbio_buffer ssl/ssl_lib.c:5791
    #2 state_machine ssl/statem/statem.c:476
    ...
    #8 SSL_read_ex ssl/ssl_lib.c:2608
    #9 server_conn_thread test/dtls_multithread_test.c:86

  Previous write of size 8 by thread T1:
    #0 BIO_pop crypto/bio/bio_lib.c:803
    #1 ssl_free_wbio_buffer ssl/ssl_lib.c:5804
    #2 tls_finish_handshake ssl/statem/statem_lib.c:1444
    ...
    #11 SSL_read_ex ssl/ssl_lib.c:2608
    #12 server_conn_thread test/dtls_multithread_test.c:86

  Location is heap block allocated by main thread:
    #6 BIO_new_dgram crypto/bio/bss_dgram.c:251
    #7 create_listener_ex test/dtls_multithread_test.c:207

Reproduce:

CC=clang ./config --strict-warnings no-shared no-fips -g -fsanitize=thread
make test TESTS=test_dtls_multithread V=1

Activity

  1. self-assigned this
    on Oct 11, 2026
  2. added theissue type on Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

triaged: bugThe issue/pr is/fixes a bug

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions