CoreOffice / XMLCoder

Easy XML parsing using Codable protocols in Swift
https://coreoffice.github.io/XMLCoder/
MIT License
800 stars 112 forks source link

EXC_BAD_ACCESS when running tests #153

Closed futuretap closed 4 years ago

futuretap commented 4 years ago

When I download the current master branch from scratch and run the tests on the 13.2.2 simulator (from Xcode 11.2.1 (11B500)), it crashes with EXC_BAD_ACCESS. Any idea what's going wrong?

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x12064a034)
    frame #0: 0x000000012064a034 XMLCoderTests
    frame #1: 0x00000001205af954 XMLCoderTests`XMLKeyedDecodingContainer.init(decoder=0x00007fe2a2f9d4c0, container=0x00007fe2a2fa5680) at XMLKeyedDecodingContainer.swift:37:19
    frame #2: 0x00000001205a4afd XMLCoderTests`XMLDecoderImplementation.keyedContainer<Key>(self=0x00007fe2a2f9d4c0) at XMLDecoderImplementation.swift:111:72
    frame #3: 0x00000001205a3e9a XMLCoderTests`XMLDecoderImplementation.container<Key>(keyType=XMLCoderTests.Foo.CodingKeys, self=0x00007fe2a2f9d4c0) at XMLDecoderImplementation.swift:77:24
    frame #4: 0x00000001205a712b XMLCoderTests`protocol witness for Decoder.container<A>(keyedBy:) in conformance XMLDecoderImplementation at <compiler-generated>:0
    frame #5: 0x0000000120dfd158 libswiftCore.dylib`dispatch thunk of Swift.Decoder.container<A where A1: Swift.CodingKey>(keyedBy: A1.Type) throws -> Swift.KeyedDecodingContainer<A1> + 8
    frame #6: 0x00000001203cd5c2 XMLCoderTests`Foo.init(decoder=0x00007fe2a2f9d4c0) at <compiler-generated>:0
    frame #7: 0x00000001203ce5c3 XMLCoderTests`protocol witness for Decodable.init(from:) in conformance Foo at <compiler-generated>:0
    frame #8: 0x0000000120dfd0f7 libswiftCore.dylib`dispatch thunk of Swift.Decodable.init(from: Swift.Decoder) throws -> A + 7
    frame #9: 0x00000001205ad950 XMLCoderTests`XMLDecoderImplementation.unbox<T>(box=XMLCoder.KeyedBox @ 0x00007fe2a2fb06c0, self=0x00007fe2a2f9d4c0) at XMLDecoderImplementation.swift:457:36
    frame #10: 0x000000012059e815 XMLCoderTests`XMLDecoder.decode<T>(type=XMLCoderTests.Foo, data=62 bytes, self=0x00007fe2a2f42ba0) at XMLDecoder.swift:369:28
  * frame #11: 0x00000001203d467f XMLCoderTests`AttributedIntrinsicTest.testDecode(self=0x00007fe2a2c929e0) at AttributedIntrinsicTest.swift:209:32
    frame #12: 0x00000001203d54ca XMLCoderTests`@objc AttributedIntrinsicTest.testDecode() at <compiler-generated>:0
    frame #13: 0x000000010aac456c CoreFoundation`__invoking___ + 140
    frame #14: 0x000000010aac4440 CoreFoundation`-[NSInvocation invoke] + 320
    frame #15: 0x0000000109ed4a21 XCTest`__24-[XCTestCase invokeTest]_block_invoke.208 + 78
    frame #16: 0x0000000109f2eb49 XCTest`-[XCTestCase(Failures) performFailableBlock:testCaseRun:shouldInterruptTest:] + 57
    frame #17: 0x0000000109f2ea67 XCTest`-[XCTestCase(Failures) _performTurningExceptionsIntoFailuresInterruptAfterHandling:block:] + 96
    frame #18: 0x0000000109ed450a XCTest`__24-[XCTestCase invokeTest]_block_invoke + 1153
    frame #19: 0x0000000109ed3fe2 XCTest`-[XCTestCase testContextPerformInScope:] + 211
    frame #20: 0x0000000109ed407c XCTest`-[XCTestCase invokeTest] + 137
    frame #21: 0x0000000109ed5ded XCTest`__26-[XCTestCase performTest:]_block_invoke_2 + 43
    frame #22: 0x0000000109f2eb49 XCTest`-[XCTestCase(Failures) performFailableBlock:testCaseRun:shouldInterruptTest:] + 57
    frame #23: 0x0000000109f2ea67 XCTest`-[XCTestCase(Failures) _performTurningExceptionsIntoFailuresInterruptAfterHandling:block:] + 96
    frame #24: 0x0000000109ed5d04 XCTest`__26-[XCTestCase performTest:]_block_invoke.334 + 88
    frame #25: 0x0000000109f42352 XCTest`+[XCTContext runInContextForTestCase:block:] + 219
    frame #26: 0x0000000109ed5473 XCTest`-[XCTestCase performTest:] + 668
    frame #27: 0x0000000109f1a997 XCTest`-[XCTest runTest] + 57
    frame #28: 0x0000000109ecfa4a XCTest`__27-[XCTestSuite performTest:]_block_invoke + 365
    frame #29: 0x0000000109ecf174 XCTest`-[XCTestSuite _performProtectedSectionForTest:testSection:] + 54
    frame #30: 0x0000000109ecf471 XCTest`-[XCTestSuite performTest:] + 355
    frame #31: 0x0000000109f1a997 XCTest`-[XCTest runTest] + 57
    frame #32: 0x0000000109ecfa4a XCTest`__27-[XCTestSuite performTest:]_block_invoke + 365
    frame #33: 0x0000000109ecf174 XCTest`-[XCTestSuite _performProtectedSectionForTest:testSection:] + 54
    frame #34: 0x0000000109ecf471 XCTest`-[XCTestSuite performTest:] + 355
    frame #35: 0x0000000109f1a997 XCTest`-[XCTest runTest] + 57
    frame #36: 0x0000000109ecfa4a XCTest`__27-[XCTestSuite performTest:]_block_invoke + 365
    frame #37: 0x0000000109ecf174 XCTest`-[XCTestSuite _performProtectedSectionForTest:testSection:] + 54
    frame #38: 0x0000000109ecf471 XCTest`-[XCTestSuite performTest:] + 355
    frame #39: 0x0000000109f1a997 XCTest`-[XCTest runTest] + 57
    frame #40: 0x0000000109f512fe XCTest`__44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke + 171
    frame #41: 0x0000000109f51401 XCTest`__44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke.84 + 118
    frame #42: 0x0000000109ee9793 XCTest`-[XCTestObservationCenter _observeTestExecutionForBlock:] + 588
    frame #43: 0x0000000109f510bd XCTest`-[XCTTestRunSession runTestsAndReturnError:] + 623
    frame #44: 0x0000000109eb2fd7 XCTest`-[XCTestDriver runTestsAndReturnError:] + 456
    frame #45: 0x0000000109f3e5a4 XCTest`_XCTestMain + 2484
    frame #46: 0x0000000109381c1b xctest`main + 267
    frame #47: 0x000000010e4e3d81 libdyld.dylib`start + 1
    frame #48: 0x000000010e4e3d81 libdyld.dylib`start + 1
MaxDesiatov commented 4 years ago

Hi @futuretap, this seems to be a duplicate of #150, which is also linked in our requirements section in a note about Xcode 11.2 (also applicable to Xcode 11.2.1). Does a workaround described in that issue work for you?

futuretap commented 4 years ago

Don't know how to set DEAD_CODE_STRIPPING on the Swift package (since there's no Xcode target with build settings). But running the test on the Mac directly instead of in the sim worked.

MaxDesiatov commented 4 years ago

@futuretap you don't have to set DEAD_CODE_STRIPPING on the package, setting it on the target that links with XMLCoder module should be enough

futuretap commented 4 years ago

I have no target. I simply opened the project and ran the included tests.

MaxDesiatov commented 4 years ago

Hm, I can't reproduce it locally. If you have a chance to try on the latest Xcode 11.3 beta 1 (11C24b as of now, but hopefully GM too when it's released), curious to know if that as well fixes the issue for you.

MaxDesiatov commented 4 years ago

Xcode 11.3 has been released and the issue is not reproducible with that version, as far as I'm aware. I've also prepared #158 with updates to README.md that clarify this and recommend using Xcode 11.3 or later instead of Xcode 11.2. I think this issue can be closed now accordingly.