-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Segmentation fault when misusing runSynchronously by passing serial executor when enqueueing as task executor #71307
Comments
Thanks for the issue about this as we chatter earlier -- I'll investigate |
This is executing as a task executor, so it must pass the self as task executor, not some arbitrary other object as serial executor: This currently does: //@available(macOS 15.0, *)
//extension EventLoop {
// @inlinable
// public func enqueue(_ job: consuming ExecutorJob) {
// let unownedJob = UnownedJob(job)
// self.execute {
// unownedJob.runSynchronously(on: self.asUnownedSerialExecutor())
// }
// }
//} but it should: func enqueue(_ job: consuming ExecutorJob) {
// eventLoop.enqueue(job)
let unownedJob = UnownedJob(job)
print("Job = \(unownedJob)")
self.eventLoop.execute {
unownedJob.runSynchronously(on: self.asUnownedTaskExecutor())
}
} this works correctly, but we should diagnose better. I'll investigate this more and follow up with improving docs and diagnostics |
I just thought about this and it is going to make it almost impossible to implement both serial and task executor on a single type right? The protocol requirement for enqueue is exactly the same so how do we know if we need to pass self as an unowned serial or task executor? |
… type This showcases some of the usage patterns that the issue swiftlang#71307 was confused about.
That's why we have the
I've been doing some more testing here and I think things work out fine, the OP a bit confused and we talked it through as well. So the enqueues are looking to be fine I think... For the preconditions you also have the |
… type This showcases some of the usage patterns that the issue swiftlang#71307 was confused about.
Description
I've created a task executor based on a SwiftNIO EventLoop, and spawned tasks to a discarding task group for handling new clients connecting to my TCP server. Once I attach the executor, the example crashes.
Reproduction
Stack dump
Expected behavior
Task runs on the EventLoop
Environment
Apple Swift version 5.11-dev (LLVM 0c7051c13ba8526, Swift 192d275)
Target: arm64-apple-macosx14.0
Additional information
No response
The text was updated successfully, but these errors were encountered: