Skip to content
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

[SR-11333] OperationQueue work not properly with Operation dependency #4484

Closed
swift-ci opened this issue Aug 20, 2019 · 2 comments
Closed

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-11333
Radar None
Original Reporter DannyLiu (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode: Version 10.3 (10G8)

macos: 10.14.6 (18G87)

swift-corelibs-foundation: tag swift-5.0-RELEASE ~ swift-5.0.2-RELEASE

swift-5.1 has a similar problem.

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: 8ceaa0baef5b0f9f960fe3fc42ba6b8b

Issue Description:

Create a test like that:

    func test_OperationDependencies() {
        let queue = OperationQueue()
        queue.maxConcurrentOperationCount = 1
        let op1 = BlockOperation {
            print("execute op1")
        }
        let op2 = BlockOperation {
            print("execute op2")
        }
        op1.addDependency(op2)
        queue.addOperation(op1)
        queue.addOperation(op2)
        queue.waitUntilAllOperationsAreFinished()
    }

The process will hangout when running the test case.

However, this test works fine with Foundation on Darwin. I read the source of Operation.swift, there should be a bug for the implementation of dependency logic.

@spevans
Copy link
Collaborator

spevans commented Jun 26, 2020

This was fixed in 5.1 but then 5.2 became broken again. It is now fixed in master

5.1.5

$ ~/swift-5.1.5-RELEASE-ubuntu18.04/usr/bin/swift sr-11333.swift
Adding Op1 dependency
Add op1
Add op2
waiting
execute op1
execute op2
$ 

5.2.3

$ ~/swift-5.2.3-RELEASE-ubuntu18.04/usr/bin/swift sr-11333.swift
Adding Op1 dependency
Add op1
Add op2
waiting
execute op2
execute op1
Stack dump:
0.      Program arguments: /home/spse/swift-5.2.3-RELEASE-ubuntu18.04/usr/bin/swift -frontend -interpret swift-corelibs-foundation/jiras/sr-11333.swift -disable-objc-interop -color-diagnostics -module-name main 
1.      Swift version 5.2.3 (swift-5.2.3-RELEASE)
2.      While running user code "swift-corelibs-foundation/jiras/sr-11333.swift"
/home/spse/swift-5.2.3-RELEASE-ubuntu18.04/usr/bin/swift[0x4be18f4]
/home/spse/swift-5.2.3-RELEASE-ubuntu18.04/usr/bin/swift[0x4bdf4ce]
/home/spse/swift-5.2.3-RELEASE-ubuntu18.04/usr/bin/swift[0x4be1bb6]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12890)[0x7fe45f15a890]
/home/spse/swift-5.2.3-RELEASE-ubuntu18.04/usr/lib/swift/linux/libFoundation.so($s10Foundation14OperationQueueC11_operations17includingBarriersSayAA0B0CGSb_tF+0x18)[0x7fe458a04c68]
/home/spse/swift-5.2.3-RELEASE-ubuntu18.04/usr/lib/swift/linux/libFoundation.so($s10Foundation14OperationQueueC33waitUntilAllOperationsAreFinishedyyF+0x80)[0x7fe458a06c00]
[0x7fe45f57d354]
[0x7fe45f57d027]
/home/spse/swift-5.2.3-RELEASE-ubuntu18.04/usr/bin/swift[0x50af89]
/home/spse/swift-5.2.3-RELEASE-ubuntu18.04/usr/bin/swift[0x50f430]
/home/spse/swift-5.2.3-RELEASE-ubuntu18.04/usr/bin/swift[0x4fc10e]
/home/spse/swift-5.2.3-RELEASE-ubuntu18.04/usr/bin/swift[0x4f127b]
/home/spse/swift-5.2.3-RELEASE-ubuntu18.04/usr/bin/swift[0x4e69c6]
/home/spse/swift-5.2.3-RELEASE-ubuntu18.04/usr/bin/swift[0x4e37c1]
/home/spse/swift-5.2.3-RELEASE-ubuntu18.04/usr/bin/swift[0x4753b5]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7fe45d7a8b97]
/home/spse/swift-5.2.3-RELEASE-ubuntu18.04/usr/bin/swift[0x474fea]
Segmentation fault (core dumped)
$

master

$ ~/swift-build/swift-DEVELOPMENT-SNAPSHOT-2020-06-22-a-ubuntu18.04/usr/bin/swift sr-11333.swift 
Adding Op1 dependency
Add op1
Add op2
waiting
execute op2
execute op1
$ 

There are some OperationQueue fixes that have been applied to master and are being backported to 5.3 in #2831

@spevans
Copy link
Collaborator

spevans commented Jan 16, 2021

Fixed in 5.3

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants