Skip to content

Is AsyncThrowingStream thread safe? #1

Description

@paulz

When we write to the stream and read from multiple threads we see thread sanitizer warnings:

SUMMARY: ThreadSanitizer: data race AsyncSequencePublisher.swift in (1) await resume partial function for closure #1 in ...
==================
ThreadSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report.
==================
WARNING: ThreadSanitizer: data race (pid=26261)
  Read of size 8 at 0x7b6400030cf0 by thread T4:
    #0 (1) await resume partial function for closure #1 in static ...
    #1 swift::runJobInEstablishedExecutorContext(swift::Job*) <null>:2 (libswift_Concurrency.dylib:x86_64+0x2a4b5)

  Previous write of size 8 at 0x7b6400030cf0 by thread T3:
    #0 closure #1 in ... 
    #1 swift::runJobInEstablishedExecutorContext(swift::Job*) <null>:2 (libswift_Concurrency.dylib:x86_64+0x2a4b5)

  Location is heap block of size 1032 at 0x7b6400030c00 allocated by thread T3:
    #0 malloc <null>:2 (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x533ac)
    #1 swift::StackAllocator<1000ul, &(swift::TaskAllocatorSlabMetadata)>::getSlabForAllocation(unsigned long) <null>:2 (libswift_Concurrency.dylib:x86_64+0x2f19a)
    #2 swift::runJobInEstablishedExecutorContext(swift::Job*) <null>:2 (libswift_Concurrency.dylib:x86_64+0x2a4b5)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions