We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attachment: Download
md5: 91cf68bf77060dfb66150dd2bc982357
Issue Description:
This easy program that should be thread synchronised just fine thanks to Dispatch fails TSan on Linux:
import Dispatch var a: Int = 0 let q = DispatchQueue(label: "q") q.async { a += 1 } let aViaThread = q.sync { () -> Int in a += 1 return a } print(aViaThread)
compiled with
swiftc -sanitize=thread test.swift
and then run with
./test
should raise no TSan (thread sanitizer) warnings on both Linux and macOS. It works just fine on Darwin but fails TSan on Linux:
$ ./test ================== WARNING: ThreadSanitizer: data race (pid=1) Write of size 8 at 0x7b0c00000020 by main thread: #​0 free /code/workspace/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:621:3 (test+0xe461) #​1 _T08Dispatch0A5QueueC5asyncyAA0A5GroupCSg5group_AA0A3QoSV3qosAA0A13WorkItemFlagsV5flagsyyXB7executetF <null> (libdispatch.so+0x3c4ef) #​2 __libc_start_main <null> (libc.so.6+0x21ec4) Previous read of size 8 at 0x7b0c00000020 by thread T1: #​0 _T0Ieg_IeyB_TR <null> (test+0xbe59) #​1 _dispatch_call_block_and_release <null> (libdispatch.so+0x4d566) Thread T1 (tid=8, running) created by main thread at: #​0 pthread_create /code/workspace/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:889:3 (test+0xf9e3) #​1 _dispatch_global_queue_poke_slow <null> (libdispatch.so+0x59665) #​2 __libc_start_main <null> (libc.so.6+0x21ec4) SUMMARY: ThreadSanitizer: data race (/usr/lib/swift/linux/libdispatch.so+0x3c4ef) in _T08Dispatch0A5QueueC5asyncyAA0A5GroupCSg5group_AA0A3QoSV3qosAA0A13WorkItemFlagsV5flagsyyXB7executetF ================== ================== WARNING: ThreadSanitizer: data race (pid=1) Write of size 8 at 0x7b0c00000028 by main thread: #​0 free /code/workspace/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:621:3 (test+0xe461) #​1 _T08Dispatch0A5QueueC5asyncyAA0A5GroupCSg5group_AA0A3QoSV3qosAA0A13WorkItemFlagsV5flagsyyXB7executetF <null> (libdispatch.so+0x3c4ef) #​2 __libc_start_main <null> (libc.so.6+0x21ec4) Previous read of size 8 at 0x7b0c00000028 by thread T1: #​0 _T0Ieg_IeyB_TR <null> (test+0xbe71) #​1 _dispatch_call_block_and_release <null> (libdispatch.so+0x4d566) Thread T1 (tid=8, running) created by main thread at: #​0 pthread_create /code/workspace/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:889:3 (test+0xf9e3) #​1 _dispatch_global_queue_poke_slow <null> (libdispatch.so+0x59665) #​2 __libc_start_main <null> (libc.so.6+0x21ec4) SUMMARY: ThreadSanitizer: data race (/usr/lib/swift/linux/libdispatch.so+0x3c4ef) in _T08Dispatch0A5QueueC5asyncyAA0A5GroupCSg5group_AA0A3QoSV3qosAA0A13WorkItemFlagsV5flagsyyXB7executetF ================== ================== WARNING: ThreadSanitizer: Swift access race (pid=1) Modifying access of Swift variable at 0x5569bb345c88 by main thread: #​0 _T04testSiycfU0_ <null> (test+0xbf95) #​1 _T0Sis5Error_pIgdzo_SisAA_pIgrzo_TR <null> (test+0xc07d) #​2 _T0Sis5Error_pIgdzo_SisAA_pIgrzo_TRTA <null> (test+0xc25e) #​3 _T08Dispatch0A5QueueC11_syncHelper33_F417D752D2C4E9330E1C700411CE0C6ALLxyyycc2fn_xyKc7executexs5Error_pKc6rescuetKlFyxyKccfU_yycfU_ <null> (libdispatch.so+0x3c73b) #​4 __libc_start_main <null> (libc.so.6+0x21ec4) Previous write of size 8 at 0x5569bb345c88 by thread T1: #​0 _T04testyycfU_ <null> (test+0xbe08) #​1 _T0Ieg_IeyB_TR <null> (test+0xbe90) #​2 _dispatch_call_block_and_release <null> (libdispatch.so+0x4d566) Location is global '_T04test1aSivp' of size 8 at 0x5569bb345c88 (test+0x0000000b1c88) Thread T1 (tid=8, running) created by main thread at: #​0 pthread_create /code/workspace/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:889:3 (test+0xf9e3) #​1 _dispatch_global_queue_poke_slow <null> (libdispatch.so+0x59665) #​2 __libc_start_main <null> (libc.so.6+0x21ec4) SUMMARY: ThreadSanitizer: Swift access race (/tmp/test+0xbf95) in _T04testSiycfU0_ ================== 2 ThreadSanitizer: reported 3 warnings
environment: Swift 4.1 release
The text was updated successfully, but these errors were encountered:
CC phabouzit (JIRA User) and @kubamracek
Sorry, something went wrong.
CC das (JIRA User)
@swift-ci create
@yln this should be fixed, right?
Yes, this is fixed on Linux starting with Swift 5.1.
yln
No branches or pull requests
Attachment: Download
Additional Detail from JIRA
md5: 91cf68bf77060dfb66150dd2bc982357
Issue Description:
This easy program that should be thread synchronised just fine thanks to Dispatch fails TSan on Linux:
compiled with
and then run with
should raise no TSan (thread sanitizer) warnings on both Linux and macOS. It works just fine on Darwin but fails TSan on Linux:
environment: Swift 4.1 release
The text was updated successfully, but these errors were encountered: