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

toEventually hangs forever when using SPM #708

Closed
1 task done
tomquist opened this issue Nov 6, 2019 · 16 comments · Fixed by #711
Closed
1 task done

toEventually hangs forever when using SPM #708

tomquist opened this issue Nov 6, 2019 · 16 comments · Fixed by #711

Comments

@tomquist
Copy link
Contributor

tomquist commented Nov 6, 2019

  • I have read CONTRIBUTING and have done my best to follow them.

What did you do?

I switched from Carthage to Swift Package Manager for integrating Quick and Nimble into a project. My tests use toEventually() in some places.

What did you expect to happen?

toEventually() should either finish or timeout eventually.

What actually happened instead?

toEventually() never stops, it polls forever and doesn't even timeout. I tried to debug the issue by setting a breakpoint in AwaitPromise.resolveResult()

func resolveResult(_ result: AwaitResult<T>) -> Bool {
if signal.wait(timeout: .now()) == .success {
self.asyncResult = result
return true
} else {
return false
}
}

however, the code seems to never be executed. I also set a breakpoint here
if promise.resolveResult(.completed(result)) {
and observed that the line is called which is really strange.

When executing tests in Release configuration everything works as expected so I assume this is a compiler bug.

Environment

List the software versions you're using:

  • Quick: 2.2.0
  • Nimble: 8.0.4
  • Xcode Version: 11.2 (11B52) (Open Xcode; In menubar: Xcode > About Xcode)
  • Swift Version: 5.1.2 (Xcode Default) (Open Xcode Preferences; Components > Toolchains. If none, use Xcode Default.)

Please also mention which package manager you used and its version. Delete the
other package managers in this list:

Swift Package Manager 5.1.0 (swiftpm-15502) (Use swift build --version in Terminal)

Project that demonstrates the issue

https://github.com/tomquist/NimbleStallBug

@danielsaidi
Copy link
Contributor

danielsaidi commented Nov 11, 2019

Thanks for moving this to the correct place!

I can verify that running the tests with release configuration works, but I use a mock library that resolves function addresses in a way that fails when tests run in release configuration.

@tomquist
Copy link
Contributor Author

Yes, me mentioning that it works in release configuration was not meant as a solution but more of an information to be able to track down the issue. I'd also try to fix it myself but I don't really know where to start here and currently don't have the time to further investigate so would be happy if somebody could look into this in more detail.

@danielsaidi
Copy link
Contributor

Sorry, that was not how I meant it. I rather meant that the release approach could have worked as a workaround until this is fixed (which would make it a less blocking bug), but that it doesn't work due to the mock problems.

@jjoelson
Copy link

I am seeing this same issue using SPM and only on Xcode 11.2. Prior to updating to 11.2 there was no issues, which makes me think @tomquist may be right about this being a compiler bug.

@jjoelson
Copy link

After more experimentation, setting DEAD_CODE_STRIPPING = NO fixed the issue, so I think the root cause is the compiler bug SR-11564. I guess disabling dead code stripping is the workaround until this is fixed.

@danielsaidi
Copy link
Contributor

I already have dead code stripping disabled for my framework and test target, and it hangs.

tomquist added a commit to tomquist/Nimble that referenced this issue Nov 12, 2019
Swift package manager uses -dead_strip as a linker flag
which falsefully strips away a method that is actually not
dead code (https://bugs.swift.org/browse/SR-11564).

Making AwaitPromise final fixes the problem for now
and shouldn’t have a negative effect.

Fixes Quick#708
tomquist added a commit to tomquist/Nimble that referenced this issue Nov 17, 2019
Swift package manager uses -dead_strip as a linker flag
which falsefully strips away a method that is actually not
dead code (https://bugs.swift.org/browse/SR-11564).

Making AwaitPromise final fixes the problem for now
and shouldn’t have a negative effect.

Fixes Quick#708
@danielsaidi
Copy link
Contributor

@tomquist This is no longer a problem in Xcode 11.3. toEventually works great.

@tomquist
Copy link
Contributor Author

@danielsaidi Yes, can confirm but I'd still merge this PR since it

  1. Adds a CI job for testing Nimble when built by the Xcode SPM version
  2. Might be still relevant for users that can't instantly update to 11.3

@danielsaidi
Copy link
Contributor

Yeah, it would be great to get it merged. I wonder what's going on with the radio silence?

ikesyo pushed a commit that referenced this issue Dec 15, 2019
Swift package manager uses -dead_strip as a linker flag
which falsefully strips away a method that is actually not
dead code (https://bugs.swift.org/browse/SR-11564).

Making AwaitPromise final fixes the problem for now
and shouldn’t have a negative effect.

Fixes #708
@ikesyo
Copy link
Member

ikesyo commented Dec 28, 2019

v8.0.5 has been released.

@danielsaidi
Copy link
Contributor

@ikesyo Great! However, CwlPreconditionTesting still crashes, like we've discussed before. You said that replacing that it requires a major version bump, right?

@AnthonyMDev
Copy link
Contributor

I'm still getting hanging forever on Xcode 11.3 with Nimble v8.0.5. Mine is happening on waitUntil though.

Can we re-open this and investigate further, or should I make a new ticket?

Stacktrace:

#0	0x00007fff523b621a in mach_msg_trap ()
#1	0x00007fff523b67f8 in mach_msg ()
#2	0x00007fff23bd3cf5 in __CFRunLoopServiceMachPort ()
#3	0x00007fff23bcea17 in __CFRunLoopRun ()
#4	0x00007fff23bce066 in CFRunLoopRunSpecific ()
#5	0x00007fff2576b86f in -[NSRunLoop(NSRunLoop) runMode:beforeDate:] ()
#6	0x000000010f217cc5 in closure #3 in AwaitPromiseBuilder.wait(_:file:line:) at ~/Documents/repo/project/Pods/Nimble/Sources/Nimble/Utils/Await.swift:261
#7	0x000000010f20e96c in thunk for @callee_guaranteed () -> () ()
#8	0x000000010f20e9d1 in thunk for @escaping @callee_guaranteed () -> () ()
#9	0x000000010f208ff8 in -[NMBExceptionCapture tryBlock:] at ~/Documents/repos/project/Pods/Nimble/Sources/NimbleObjectiveC/NMBExceptionCapture.m:21
#10	0x000000010f217770 in AwaitPromiseBuilder.wait(_:file:line:) at ~/Documents/repos/project/Pods/Nimble/Sources/Nimble/Utils/Await.swift:251
#11	0x000000010f249879 in static NMBWait.throwableUntil(timeout:file:line:action:) at ~/Documents/repos/project/Pods/Nimble/Sources/Nimble/DSL+Wait.swift:67
#12	0x000000010f2492d1 in static NMBWait.until(timeout:file:line:action:) at ~/Documents/repos/project/Pods/Nimble/Sources/Nimble/DSL+Wait.swift:24
#13	0x000000010f24b6ac in waitUntil(timeout:file:line:action:) at ~/Documents/repos/project/Pods/Nimble/Sources/Nimble/DSL+Wait.swift:121

@tomquist
Copy link
Contributor Author

tomquist commented Jan 2, 2020

@AnthonyMDev would be great if you could create a PR with a test case that produces this bug when run using ./test ios_xcodespm

@AnthonyMDev
Copy link
Contributor

I'll try my best. I've got a complicated test suite and it's happening semi-sporadically so not sure how to reproduce it... I'll update you.

@AnthonyMDev
Copy link
Contributor

@tomquist Looks like this is already reported and an open issue. #509
Can we track this there? It's open, but is not active recently.

@ikesyo
Copy link
Member

ikesyo commented Jan 3, 2020

The issue @AnthonyMDev is facing seems like a duplicate of #509.

@Quick Quick locked as resolved and limited conversation to collaborators Jan 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants