-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
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
ThreadSanitizer reports data race at File.lines.getter
on xcodebuild test -enableThreadSanitizer YES
#2089
Comments
Fixed in #2090 |
Sorry, I did not think that this issue will be fixed in #2090. |
I see. Thanks! |
I understand why it did not occur in the tsan job of CircleCI which existed before. $ swift run -Xswiftc -sanitize=thread swiftlint lint --lenient --no-cache --path Package.swift
Loading configuration from '.swiftlint.yml'
Linting Swift files at path Package.swift
Linting 'Package.swift' (1/1)
==================
WARNING: ThreadSanitizer: data race (pid=38440)
Read of size 8 at 0x7b1800006590 by thread T5:
* #0 File.lines.getter File.swift:37 (swiftlint:x86_64+0x1000e6136)
#1 TrailingWhitespaceRule.validate(file:) TrailingWhitespaceRule.swift:32 (swiftlint:x86_64+0x1006b82fb)
#2 protocol witness for Rule.validate(file:) in conformance TrailingWhitespaceRule TrailingWhitespaceRule.swift (swiftlint:x86_64+0x1006bceb0)
#3 Rule.lint(file:regions:benchmark:superfluousDisableCommandRule:) Linter.swift:71 (swiftlint:x86_64+0x1002bc733)
#4 closure #2 in Linter.getStyleViolations(benchmark:) Linter.swift:138 (swiftlint:x86_64+0x1002cef1b)
#5 partial apply for closure #2 in Linter.getStyleViolations(benchmark:) Linter.swift (swiftlint:x86_64+0x1002d785c)
#6 thunk for @callee_owned (@in Rule) -> (@owned LintResult?) Linter.swift (swiftlint:x86_64+0x1002cf1ea)
#7 partial apply for thunk for @callee_owned (@in Rule) -> (@owned LintResult?) Linter.swift (swiftlint:x86_64+0x1002d7949)
#8 closure #1 in closure #1 in Array.parallelMap<A>(transform:) Array+SwiftLint.swift:66 (swiftlint:x86_64+0x100214779)
#9 partial apply for closure #1 in closure #1 in Array.parallelMap<A>(transform:) Array+SwiftLint.swift (swiftlint:x86_64+0x100214f51)
#10 thunk for @callee_owned (@unowned Int) -> () <null>:3204080 (libswiftDispatch.dylib:x86_64+0xb5a6)
#11 _dispatch_client_callout2 <null>:3204080 (libdispatch.dylib:x86_64+0xc167)
Previous write of size 8 at 0x7b1800006590 by thread T6 (mutexes: write M1368):
* #0 File.lines.getter File.swift:38 (swiftlint:x86_64+0x1000e6270)
#1 File.syntaxTokensByLine() File+SwiftLint.swift:155 (swiftlint:x86_64+0x1002643fe)
#2 closure #1 in variable initialization expression of syntaxTokensByLinesCache File+Cache.swift:31 (swiftlint:x86_64+0x100250a89)
#3 thunk for @callee_owned (@owned File) -> (@owned [[SyntaxToken]]?) File+Cache.swift (swiftlint:x86_64+0x100250b03)
#4 partial apply for thunk for @callee_owned (@owned File) -> (@owned [[SyntaxToken]]?) File+Cache.swift (swiftlint:x86_64+0x100256529)
#5 Cache.get(_:) File+Cache.swift:73 (swiftlint:x86_64+0x1002522f7)
#6 File.syntaxTokensByLines.getter File+Cache.swift:152 (swiftlint:x86_64+0x100254a06)
#7 ClosureSpacingRule.validBraces(in:) ClosureSpacingRule.swift:84 (swiftlint:x86_64+0x1003824c1)
#8 ClosureSpacingRule.findViolations(file:) ClosureSpacingRule.swift:129 (swiftlint:x86_64+0x1003843b8)
#9 ClosureSpacingRule.validate(file:) ClosureSpacingRule.swift:146 (swiftlint:x86_64+0x1003860d9)
#10 protocol witness for Rule.validate(file:) in conformance ClosureSpacingRule ClosureSpacingRule.swift (swiftlint:x86_64+0x10038aea4)
#11 Rule.lint(file:regions:benchmark:superfluousDisableCommandRule:) Linter.swift:71 (swiftlint:x86_64+0x1002bc733)
#12 closure #2 in Linter.getStyleViolations(benchmark:) Linter.swift:138 (swiftlint:x86_64+0x1002cef1b)
#13 partial apply for closure #2 in Linter.getStyleViolations(benchmark:) Linter.swift (swiftlint:x86_64+0x1002d785c)
#14 thunk for @callee_owned (@in Rule) -> (@owned LintResult?) Linter.swift (swiftlint:x86_64+0x1002cf1ea)
#15 partial apply for thunk for @callee_owned (@in Rule) -> (@owned LintResult?) Linter.swift (swiftlint:x86_64+0x1002d7949)
#16 closure #1 in closure #1 in Array.parallelMap<A>(transform:) Array+SwiftLint.swift:66 (swiftlint:x86_64+0x100214779)
#17 partial apply for closure #1 in closure #1 in Array.parallelMap<A>(transform:) Array+SwiftLint.swift (swiftlint:x86_64+0x100214f51)
#18 thunk for @callee_owned (@unowned Int) -> () <null>:3204080 (libswiftDispatch.dylib:x86_64+0xb5a6)
#19 _dispatch_client_callout2 <null>:3204080 (libdispatch.dylib:x86_64+0xc167)
Issue is caused by frames marked with "*".
Location is heap block of size 88 at 0x7b1800006540 allocated by thread T1:
#0 malloc <null>:3204112 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x48b3a)
#1 swift_slowAlloc <null>:3204112 (libswiftCore.dylib:x86_64+0x344478)
#2 File.__allocating_init(pathDeferringReading:) File.swift (swiftlint:x86_64+0x1000e71dc)
#3 partial apply for File.__allocating_init(pathDeferringReading:) Configuration+LintableFiles.swift (swiftlint:x86_64+0x1002224fe)
#4 thunk for @callee_owned (@owned String) -> (@owned File?, @error @owned Error) Configuration+LintableFiles.swift (swiftlint:x86_64+0x1002200c9)
#5 partial apply for thunk for @callee_owned (@owned String) -> (@owned File?, @error @owned Error) Configuration+LintableFiles.swift (swiftlint:x86_64+0x10022024a)
#6 Sequence.flatMap<A>(_:) <null>:3204112 (libswiftCore.dylib:x86_64+0x15fa87)
#7 Configuration.getFiles(path:action:useSTDIN:quiet:useScriptInputFiles:) Configuration+CommandLine.swift:130 (swiftlint:x86_64+0x100897db0)
#8 Configuration.visitLintableFiles(path:action:useSTDIN:quiet:useScriptInputFiles:cache:parallel:visitorBlock:) Configuration+CommandLine.swift:64 (swiftlint:x86_64+0x100895d94)
#9 Configuration.visitLintableFiles(options:cache:visitorBlock:) Configuration+CommandLine.swift:147 (swiftlint:x86_64+0x1008a71cc)
#10 LintCommand.run(_:) LintCommand.swift:47 (swiftlint:x86_64+0x10086781d)
#11 protocol witness for CommandProtocol.run(_:) in conformance LintCommand LintCommand.swift (swiftlint:x86_64+0x1008744f6)
#12 closure #1 in CommandWrapper.init<A>(_:) Command.swift:55 (swiftlint:x86_64+0x10003d263)
#13 partial apply for closure #1 in CommandWrapper.init<A>(_:) Command.swift (swiftlint:x86_64+0x10004369b)
#14 CommandRegistry.run(command:arguments:) Command.swift:109 (swiftlint:x86_64+0x10003f691)
#15 CommandRegistry.main(arguments:defaultVerb:errorHandler:) Command.swift:174 (swiftlint:x86_64+0x100040497)
#16 CommandRegistry.main(defaultVerb:errorHandler:) Command.swift:138 (swiftlint:x86_64+0x10003fd8e)
#17 closure #1 in main.swift:25 (swiftlint:x86_64+0x1008b4033)
#18 thunk for @callee_owned () -> () QueuedPrint.swift (swiftlint:x86_64+0x1002778dc)
#19 __tsan::invoke_and_release_block(void*) <null>:3204112 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x6619b)
#20 _dispatch_client_callout <null>:3204112 (libdispatch.dylib:x86_64+0x1d4f)
Mutex M1368 (0x7b180000c310) created at:
#0 pthread_mutex_init <null>:3203968 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2b213)
#1 -[NSLock init] <null>:3203968 (Foundation:x86_64+0x1d7d)
#2 NSLock.__allocating_init() Clang+SourceKitten.swift (swiftlint:x86_64+0x1000b59d4)
#3 Cache.init(_:) File+Cache.swift:60 (swiftlint:x86_64+0x100251cd7)
#4 Cache.__allocating_init(_:) File+Cache.swift (swiftlint:x86_64+0x10024f30b)
#5 globalinit_33_D93545007D2CCCB97554C3EFBF0F3773_func4 File+Cache.swift:31 (swiftlint:x86_64+0x100250a12)
#6 dispatch_once <null>:3203968 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x66e04)
#7 dispatch_once_f <null>:3203968 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x66ef6)
#8 syntaxTokensByLinesCache.unsafeMutableAddressor File+Cache.swift:31 (swiftlint:x86_64+0x100250b89)
#9 File.syntaxTokensByLines.getter File+Cache.swift:152 (swiftlint:x86_64+0x1002549a6)
#10 ClosureSpacingRule.validBraces(in:) ClosureSpacingRule.swift:84 (swiftlint:x86_64+0x1003824c1)
#11 ClosureSpacingRule.findViolations(file:) ClosureSpacingRule.swift:129 (swiftlint:x86_64+0x1003843b8)
#12 ClosureSpacingRule.validate(file:) ClosureSpacingRule.swift:146 (swiftlint:x86_64+0x1003860d9)
#13 protocol witness for Rule.validate(file:) in conformance ClosureSpacingRule ClosureSpacingRule.swift (swiftlint:x86_64+0x10038aea4)
#14 Rule.lint(file:regions:benchmark:superfluousDisableCommandRule:) Linter.swift:71 (swiftlint:x86_64+0x1002bc733)
#15 closure #2 in Linter.getStyleViolations(benchmark:) Linter.swift:138 (swiftlint:x86_64+0x1002cef1b)
#16 partial apply for closure #2 in Linter.getStyleViolations(benchmark:) Linter.swift (swiftlint:x86_64+0x1002d785c)
#17 thunk for @callee_owned (@in Rule) -> (@owned LintResult?) Linter.swift (swiftlint:x86_64+0x1002cf1ea)
#18 partial apply for thunk for @callee_owned (@in Rule) -> (@owned LintResult?) Linter.swift (swiftlint:x86_64+0x1002d7949)
#19 closure #1 in closure #1 in Array.parallelMap<A>(transform:) Array+SwiftLint.swift:66 (swiftlint:x86_64+0x100214779)
#20 partial apply for closure #1 in closure #1 in Array.parallelMap<A>(transform:) Array+SwiftLint.swift (swiftlint:x86_64+0x100214f51)
#21 thunk for @callee_owned (@unowned Int) -> () <null>:3203968 (libswiftDispatch.dylib:x86_64+0xb5a6)
#22 _dispatch_client_callout2 <null>:3203968 (libdispatch.dylib:x86_64+0xc167)
Thread T5 (tid=6333343, running) is a GCD worker thread
Thread T6 (tid=6333344, running) is a GCD worker thread
Thread T1 (tid=6333339, running) is a GCD worker thread
SUMMARY: ThreadSanitizer: data race File.swift:37 in File.lines.getter
==================
/Users/norio/github/SwiftLint/Package.swift:1:1: warning: File Header Violation: Header comments should be consistent with project patterns. (file_header)
/Users/norio/github/SwiftLint/Package.swift:14:90: warning: Trailing Comma Violation: Collection literals should not have trailing commas. (trailing_comma)
/Users/norio/github/SwiftLint/Package.swift:22:34: warning: Trailing Comma Violation: Collection literals should not have trailing commas. (trailing_comma)
/Users/norio/github/SwiftLint/Package.swift:29:23: warning: Trailing Comma Violation: Collection literals should not have trailing commas. (trailing_comma)
/Users/norio/github/SwiftLint/Package.swift:38:28: warning: Trailing Comma Violation: Collection literals should not have trailing commas. (trailing_comma)
Done linting! Found 5 violations, 0 serious in 1 file.
ThreadSanitizer: reported 1 warnings |
norio-nomura
added a commit
to jpsim/SourceKitten
that referenced
this issue
Mar 14, 2018
Nice find! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: