Here it is
Thanks.
but I think you're missing the point that the same swift code works perfectly well when it's not in swift package.
It’s not that I don’t believe you, it’s that there are many different reasons why code can fail when you move it between components. For example, recently there’s been a spate of problems caused by a bug in the way that Swift handles runtime information in this case. OTOH, there’s a world of undefined behaviour that can easily trigger issues like this.
In first post I delivered everything needed to reproduce this behaviour including original swift package repository.
Right, but a quick glance at a crash report is a lot quicker than setting up a test project.
Anyway, on to your crash. Here’s those symbols demangled:
$ cat tmp.txt
$sSayxGSzRzlWOh
$s4Seed11SeedsBridgeC4syncyyF
$s4Seed11SeedsBridgeC5seedA0D1BACyxGA2ACyxG_AHtcfc
$s4Seed11SeedsBridgeC5seedA0D1BACyxGA2ACyxG_AHtcfC
$s4Seed27MultidimensionalSeedsBridgeC10dimensions12seedModifier8positionACyxGSayAA13DimensionInfoVG_SSSaySdGtcfc
$s4Seed04TimeA0C13sliceDuration8modifier4dateACyxGSi_SS10Foundation4DateVtcfc
$s4Seed04TimeA0C13sliceDuration8modifier4dateACyxGSi_SS10Foundation4DateVtcfC
$s14TEST_TO_REMOVE11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0l6LaunchK3KeyaypGSgtF
$s14TEST_TO_REMOVE11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0l6LaunchK3KeyaypGSgtFTo
$ xcrun swift-demangle < tmp.txt
outlined destroy of [A]
Seed.SeedsBridge.sync() -> ()
Seed.SeedsBridge.init(seedA: Seed.Seed<A>, seedB: Seed.Seed<A>) -> Seed.SeedsBridge<A>
Seed.SeedsBridge.__allocating_init(seedA: Seed.Seed<A>, seedB: Seed.Seed<A>) -> Seed.SeedsBridge<A>
Seed.MultidimensionalSeedsBridge.init(dimensions: [Seed.DimensionInfo], seedModifier: Swift.String, position: [Swift.Double]) -> Seed.MultidimensionalSeedsBridge<A>
Seed.TimeSeed.init(sliceDuration: Swift.Int, modifier: Swift.String, date: Foundation.Date) -> Seed.TimeSeed<A>
Seed.TimeSeed.__allocating_init(sliceDuration: Swift.Int, modifier: Swift.String, date: Foundation.Date) -> Seed.TimeSeed<A>
TEST_TO_REMOVE.AppDelegate.application(_: __C.UIApplication, didFinishLaunchingWithOptions: [__C.UIApplicationLaunchOptionsKey : Any]?) -> Swift.Bool
@objc TEST_TO_REMOVE.AppDelegate.application(_: __C.UIApplication, didFinishLaunchingWithOptions: [__C.UIApplicationLaunchOptionsKey : Any]?) -> Swift.Bool
Here’s what the last frame for your code looks like:
public func sync() {
let utilised = utilisedNumbersCount
restore(utilisedNumbersCount: utilised)
}
It seems that the crash is actually on line 2 of that, where you get the
utilisedNumbersCount
property. That property is backed by a getter, and it’s definitely crashing before it comes back from that getter, even though the getter doesn’t appear in the backtrace.
Here’s the code for that getter:
open var utilisedNumbersCount: Int {
return max(seedA.utilisedNumbersCount, seedB.utilisedNumbersCount)
}
There’s only one line here, so it’s hard to see what’s going on. I broke this up into multiple lines:
open var utilisedNumbersCount: Int {
let a = seedA.utilisedNumbersCount
let b = seedB.utilisedNumbersCount
let c = max(a, b)
return c
}
It crashes as I step over line 2.
I don’t see anything obvious here, and digging into the assembler is more work than I have time for in the context of DevForums (I did learn a lot of about this by looking at the non-ASan crash, but the ASan crash gets us closer to the problem, which is nice, and radically obfuscates the assembly, which is not).
Anyway, as I mentioned above, there have been some Swift runtime issues with Xcode 11.2 so I thought I’d try installing the latest toolchain to see if that helps (specifically, I installed yesterday’s trunk snapshot from the Swift downloads page). That didn’t fix the problem, but it did highlight a bug in your code.
Specifically, it generated dangling pointer warnings on the following two methods:
public func data() -> Data {
var mutableValue = self
let buffer = UnsafeBufferPointer(start: &mutableValue, count: 1)
return Data(buffer: buffer)
}
public func toInteger<T: BinaryInteger>() -> T {
var value: T = 0
let buffer = UnsafeMutableBufferPointer(start: &value, count: 1)
_ = copyBytes(to: buffer)
return value
}
My recommendation is that you fix these bugs and then re-test. If you continue to have problems, file a Swift bug and then ask about it over on Swift Forums.
Please post your bug number, just for the record.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"