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 on XCode 11.2 and iOS13.2 #150

Closed mrommel closed 5 years ago

mrommel commented 5 years ago

Hi, I have issues since I updated my project to XCode 11.2 and iOS13.2.

EXC_BAD_ACCESS when trying to run "Note" Sample on Simulator or Device.

Can anyone help?

I have uploaded a minimal Sample. Lib is included via SPM. Doesn't matter which version (I tried 0.7.0, 0.8.0 and 0.9.0): https://github.com/mrommel/XMLCoderiOS13_2

mrommel commented 5 years ago

Bad Access happens in XMLKeyedDecodingContainer.swift:37

self.decoder = decoder
container.withShared { <===== here
  $0.elements = .init($0.elements.map { (decoder.keyTransform($0), $1) })
  $0.attributes = .init($0.attributes.map { (decoder.keyTransform($0), $1) })
}

Stack trace

Thread 1 Queue : com.apple.main-thread (serial)
#0  0x0000000103b06544 in 0x103b06544 ()
#1  0x0000000103aa56b4 in XMLKeyedDecodingContainer.init(referencing:wrapping:) at /Users/michaelrommel/Library/Developer/Xcode/DerivedData/XMLCoderiOS13_2-basnfrogrwdfddctwofukekijrgn/SourcePackages/checkouts/XMLCoder/Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift:37
#2  0x0000000103a9ad1e in XMLDecoderImplementation.keyedContainer<A>(keyedBy:) at /Users/michaelrommel/Library/Developer/Xcode/DerivedData/XMLCoderiOS13_2-basnfrogrwdfddctwofukekijrgn/SourcePackages/checkouts/XMLCoder/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift:105
#3  0x0000000103a9a48a in XMLDecoderImplementation.container<A>(keyedBy:) at /Users/michaelrommel/Library/Developer/Xcode/DerivedData/XMLCoderiOS13_2-basnfrogrwdfddctwofukekijrgn/SourcePackages/checkouts/XMLCoder/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift:77
#4  0x0000000103a9d34b in protocol witness for Decoder.container<A>(keyedBy:) in conformance XMLDecoderImplementation ()
#5  0x00007fff512ebf88 in dispatch thunk of Decoder.container<A>(keyedBy:) ()
#6  0x00000001041a1e02 in Note.init(from:) ()
#7  0x00000001041a2a2a in protocol witness for Decodable.init(from:) in conformance Note ()
#8  0x00007fff512ebf27 in dispatch thunk of Decodable.init(from:) ()
#9  0x0000000103aa36b0 in XMLDecoderImplementation.unbox<A>(_:) at /Users/michaelrommel/Library/Developer/Xcode/DerivedData/XMLCoderiOS13_2-basnfrogrwdfddctwofukekijrgn/SourcePackages/checkouts/XMLCoder/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift:441
#10 0x0000000103a94e05 in XMLDecoder.decode<A>(_:from:) at /Users/michaelrommel/Library/Developer/Xcode/DerivedData/XMLCoderiOS13_2-basnfrogrwdfddctwofukekijrgn/SourcePackages/checkouts/XMLCoder/Sources/XMLCoder/Decoder/XMLDecoder.swift:369
#11 0x00000001041a2ec1 in XMLCoderiOS13_2Tests.testExample() at /Users/michaelrommel/Prog/XMLCoderiOS13_2/XMLCoderiOS13_2Tests/XMLCoderiOS13_2Tests.swift:43
#12 0x00000001041a383b in @objc XMLCoderiOS13_2Tests.testExample() ()
...
ydnar commented 5 years ago

Try disabling dead code stripping on your app’s project: DEAD_CODE_STRIPPING = NO

For additional context, see the underlying bug here: https://bugs.swift.org/browse/SR-11564

mrommel commented 5 years ago

Sorry for not thinking this far - thanks a thousand times.