mattgallagher / CwlPreconditionTesting

A Mach exception handler that allows Swift precondition failures to be caught and tested.
ISC License
175 stars 46 forks source link

Return of the intermittent "undeclared identifier 'BadInstructionException'" error #8

Closed lazerwalker closed 5 years ago

lazerwalker commented 7 years ago

Hi!

When my iOS app builds Nimble as part of our test suite, it often fails out with this error:

/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlBadInstructionException.swift:48:16: error: use of unresolved identifier 'bad_instruction_exception_reply_t'
                        var reply = bad_instruction_exception_reply_t(exception_port: 0, exception: 0, code: nil, codeCnt: 0, flavor: nil, old_state: nil, old_stateCnt: 0, new_state: nil, new_stateCnt: nil)
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'd say this happens 15-20% of the time on our Jenkins box, and a bit less frequently (but still non-zero) locally.

5 and #6 suggest this was a known issue, but also that it's theoretically been fixed. Is this known to still be an issue? Is there a workaround that simply needs better documentation/visibility?

(I'm not sure whether this should be opened here or in Nimble, and am opening issues in both places. My apologies if this is the wrong place, and feel free to delete/close as appropriate!)

mattgallagher commented 7 years ago

The problem was that we never totally nailed down what was happening... there was no repeatable set of instructions.

My suspicion though, is that the cause of this problem was due to the umbrella header relying on conditional compilation information (e.g. whether the target was __x8664_\). Headers are analyzed and included in the header map as an opaque process that is tricky to control – Xcode could easily be getting this wrong when switching between targets or between device and simulator.

What I've done in the latest build on CwlPreconditionTesting/master is remove all conditional compilation options from the headers (and tidied up some other minor issues that are hangovers from a move to a swift build-friendly compilation structure).

Additionally, I've created a totally separate CwlPreconditionTesting.h file for use as the umbrella header with POSIX and tvOS targets, since those targets have very different requirements.

I suggest you try this version out with Nimble. If anything will fix this issue permanently, this new approach will.

lazerwalker commented 7 years ago

Thanks so much! @jeffh was kind enough to throw together a PR updating Nimble. Given the nondeterministic nature of this, I'm giving it a day or two on our CI to make sure things seem stabler, but will ping back here when it's clearer whether this clears it up or not.

Thanks again!