Nimble: toEventually hangs forever when using SPM

Created on 6 Nov 2019  路  16Comments  路  Source: Quick/Nimble

  • [x] 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() https://github.com/Quick/Nimble/blob/9a4564effa6607cd571adbccf990bb0e6f8558db/Sources/Nimble/Utils/Await.swift#L118-L125
however, the code seems to never be executed. I also set a breakpoint here https://github.com/Quick/Nimble/blob/9a4564effa6607cd571adbccf990bb0e6f8558db/Sources/Nimble/Utils/Await.swift#L330 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

All 16 comments

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.

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.

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.

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.

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.

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

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

@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

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

v8.0.5 has been released.

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

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

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

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.

@tomquist Looks like this is already reported and an open issue. https://github.com/Quick/Nimble/issues/509
Can we track this there? It's open, but is not active recently.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aaroncrespo picture aaroncrespo  路  10Comments

ScottRobbins picture ScottRobbins  路  7Comments

kleiberjp picture kleiberjp  路  4Comments

Blackjacx picture Blackjacx  路  9Comments

hamchapman picture hamchapman  路  7Comments