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

Test suite crashes on Xcode 13.3 / Swift 5.6 #37

Closed
nighthawk opened this issue Mar 24, 2022 · 7 comments
Closed

Test suite crashes on Xcode 13.3 / Swift 5.6 #37

nighthawk opened this issue Mar 24, 2022 · 7 comments

Comments

@nighthawk
Copy link
Contributor

Running this repo's test suite on macOS 12.3 with Xcode 13.3 and Swift 5.6 crashes on my M1 MacBook Air with an EXC_BAD_ACCESS.

This happens in tests such as testTooFewArgumentsForCustomFunctionWithAdvancedInitializer and a number of other ones which test a mismatching number of arguments.

#0	0x000000016fdfcd98 in 0x16fdfcd98 ()
#1	0x00000001078bc278 in thunk for @escaping @callee_guaranteed (@in_guaranteed [Double]) -> (@out Double, @error @owned Error) ()
#2	0x00000001078f92e0 in partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed [Double]) -> (@out Double, @error @owned Error) ()
#3	0x00000001078dfba8 in Subexpression.optimized(withImpureSymbols:pureSymbols:) at /Users/adrian/Development/forks/Expression/Sources/Expression.swift:892
#4	0x00000001078de7ac in Expression.init(_:impureSymbols:pureSymbols:) at /Users/adrian/Development/forks/Expression/Sources/Expression.swift:351
#5	0x00000001078de6e0 in Expression.__allocating_init(_:impureSymbols:pureSymbols:) ()
#6	0x00000001078dfe20 in Expression.__allocating_init(_:pureSymbols:) at /Users/adrian/Development/forks/Expression/Sources/Expression.swift:372
#7	0x000000010788b350 in ExpressionTests.testTooFewArgumentsForCustomFunctionWithAdvancedInitializer() at /Users/adrian/Development/forks/Expression/Tests/ExpressionTests.swift:934

I couldn't yet narrow down what might be causing it and if it's an issue introduced with Swift 5.6 or with this library, or what to do about it. It happens both when running through Xcode or with swift test from the command line. Any advise appreciated!

@nighthawk
Copy link
Contributor Author

Screenshot of the crash in Xcode, in case it helps.

Screen Shot 2022-03-24 at 14 31 31

@nicklockwood
Copy link
Owner

Looks like a Swift 5.6 regression. I'll investigate.

@nicklockwood
Copy link
Owner

@nighthawk is the crash affecting your project, or just the test failure? If it's only the latter I can just disable the test for now.

@nighthawk
Copy link
Contributor Author

As far as I can tell, it doesn't seem to be impacting my project; just running the tests crashed.

I commented out these tests temporarily:

  • testTooFewArgumentsWithAdvancedInitializer
  • testTooFewArgumentsForCustomFunctionWithAdvancedInitializer
  • testTooManyArgumentsWithAdvancedInitializer
  • testUnknownSymbolWithAdvancedInitializer

@bhimsenp
Copy link

@nicklockwood .. Seems following line is causing the issue (Expression.swift: line 354)

if let fn = pureSymbols($0) ?? Expression.mathSymbols[$0] ?? Expression.boolSymbols[$0] {
    return fn
}

Haven't figured out the exact cause yet, but looks like there is an issue where there is cascaded nil-coalescing operation.
In one of the failing test, the fn evaluates to non-nil even when all 3 expressions are nil. Consequently, when it tries to execute line 892 (where crash is happening), it tries to execute the nil function and that's why the EXEC_BAD_ACCESS.

Adding brackets to first two correctly evaluated fn to be nil solves the crash.

if let fn = (pureSymbols($0) ?? Expression.mathSymbols[$0]) ?? Expression.boolSymbols[$0] {
    return fn
}

You can add this workaround temporarily.

@nicklockwood
Copy link
Owner

@bhimsenp thanks, that solved it!

@nicklockwood
Copy link
Owner

@nighthawk fixed in 0.13.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants