-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Description
Previous ID | SR-15108 |
Radar | rdar://problem/82306884 |
Original Reporter | beaumont (JIRA User) |
Type | Bug |
Attachment: Download
Environment
Here is a repro branch of Swift NIO: https://github.com/simonjbeaumont/swift-nio/tree/async-double-free-repro
The branch has commented out all other tests from the Package.swift and has added a single test:
`_NIOConcurrencyTests.AsyncAwaitHelpersTests.testPromiseCompletedWithSuccessfulTaskInClassAsyncWithAwaitWithYield`
The structure of types in the test is a little arbitrary since it represents an analog of an issue I was hitting in grpc-swift.
I am able to reproduce the failure reliably using the latest Swift toolchain for Xcode, `swift-5.5-DEVELOPMENT-SNAPSHOT-2021-08-23-a`, and also on Linux using, Docker image `swiftlang/swift nightly-5.5 63768f6ffe90`
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug, Concurrency |
Assignee | @kavon |
Priority | Medium |
md5: d0ed450d90301f18856997ddba42e5e5
Issue Description:
I have created a branch of Swift NIO with a test case that runs a block of code one million times. It crashes after O(10k) iterations.
Some times it segfaults, sometimes I get output about double-free but the crash itself isn't in a deterministic place, nor is the output.
From the logging in the test it appears that, when it does crash, some code that should have only been executed once is executed twice.
Here is a repro branch of Swift NIO: https://github.com/simonjbeaumont/swift-nio/tree/async-double-free-repro
The branch has commented out all other tests from the Package.swift and has added a single test:
`_NIOConcurrencyTests.AsyncAwaitHelpersTests.testPromiseCompletedWithSuccessfulTaskInClassAsyncWithAwaitWithYield`
The structure of types in the test is a little arbitrary since it represents an analog of an issue I was hitting in grpc-swift.
I am able to reproduce the failure reliably using the latest Swift toolchain for Xcode, `swift-5.5-DEVELOPMENT-SNAPSHOT-2021-08-23-a`, and also on Linux using, Docker image `swiftlang/swift nightly-5.5 63768f6ffe90`
Here is an example output:
--- Starting test iteration 6916
on thread 3 in completionHandler(_:): was success with value: OK
on thread 5 in mockError(): calling handleError(_:) with error: HandlerError()
on thread 5 in handleError(_:): failing promise with error: HandlerError()
on thread 5 in handleError(_:): canceling task
on thread 5 in deinit: .
--- Starting test iteration 6917
on thread 5 in mockError(): calling handleError(_:) with error: HandlerError()
on thread 5 in handleError(_:): failing promise with error: HandlerError()
on thread 5 in completionHandler(_:): was failure with error: HandlerError()
on thread 4 in completionHandler(_:): was failure with error: HandlerError()
on thread 5 in handleError(_:): failing promise with error: HandlerError()
on thread 4 in handleError(_:): failing promise with error: HandlerError()
on thread 5 in handleError(_:): canceling task
on thread 4 in handleError(_:): canceling task
on thread 5 in handleError(_:): canceling task
xctest(83107,0x70000bc9a000) malloc: Double free of object 0x101427570 xctest(83107,0x70000bc9a000) malloc: *** set a breakpoint in malloc_error_break to debug
It shouldn't be possible to see `canceling task` printed more than twice.