Error description: Thread 1: Fatal error: load from misaligned raw pointer
Detailed stack trace:
Thread 1 Queue : com.apple.main-thread (serial)
#0 0x00007ff81160b330 in _swift_runtime_on_report ()
#1 0x00007ff81168a2c9 in _swift_stdlib_reportFatalErrorInFile ()
#2 0x00007ff81134a763 in closure #1 in closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) ()
#3 0x00007ff81134a4cc in closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) ()
#4 0x00007ff81134a1a5 in closure #1 in _assertionFailure(_:_:file:line:flags:) ()
#5 0x00007ff811349dfa in _assertionFailure(_:_:file:line:flags:) ()
#6 0x00007ff81134a08c in _fatalErrorMessage(_:_:file:line:flags:) ()
#7 0x00007ff81142de59 in UnsafeRawBufferPointer.load<τ_0_0>(fromByteOffset:as:) ()
#8 0x000000010036715a in closure #1 in Data.UInt64.getter at /Users/yeatse/Developer/Repo/mocha/Shared/Helpers/Extensions.swift:28
#9 0x0000000100367183 in thunk for @callee_guaranteed (@unowned UnsafeRawBufferPointer) -> (@unowned UInt64, @error @owned Error) ()
#10 0x0000000100368c14 in partial apply for thunk for @callee_guaranteed (@unowned UnsafeRawBufferPointer) -> (@unowned UInt64, @error @owned Error) ()
#11 0x00007ff81560205a in Data.withUnsafeBytes<τ_0_0>(_:) ()
#12 0x0000000100367051 in Data.UInt64.getter at /Users/yeatse/Developer/Repo/mocha/Shared/Helpers/Extensions.swift:28
#13 0x000000010035766a in closure #1 in LCSourceVersion.init(with:data:translationStore:) at /Users/yeatse/Developer/Repo/mocha/Shared/Models/LoadCommand/LCSourceVersion.swift:18
#14 0x00000001002da3a0 in thunk for @callee_guaranteed (@guaranteed Data) -> (@owned String) ()
#15 0x0000000100359481 in partial apply for thunk for @callee_guaranteed (@guaranteed Data) -> (@owned String) ()
#16 0x0000000100305721 in TranslationStore.translate<τ_0_0>(next:dataInterpreter:itemContentGenerator:) at /Users/yeatse/Developer/Repo/mocha/Shared/Models/Translations/TranslationStore.swift:24
#17 0x0000000100357553 in LCSourceVersion.init(with:data:translationStore:) at /Users/yeatse/Developer/Repo/mocha/Shared/Models/LoadCommand/LCSourceVersion.swift:17
#18 0x00000001003573bd in LCSourceVersion.__allocating_init(with:data:translationStore:) ()
#19 0x000000010033ecce in Macho.init(with:machoFileName:) at /Users/yeatse/Developer/Repo/mocha/Shared/Models/Macho.swift:251
#20 0x000000010033d0dd in Macho.__allocating_init(with:machoFileName:) ()
#21 0x000000010036616a in File.init(with:fileData:) at /Users/yeatse/Developer/Repo/mocha/Shared/IO/File.swift:74
#22 0x0000000100316d29 in FatBinary.init(with:machoFileName:) at /Users/yeatse/Developer/Repo/mocha/Shared/IO/FatBinary.swift:64
#23 0x00000001003660c6 in File.init(with:fileData:) at /Users/yeatse/Developer/Repo/mocha/Shared/IO/File.swift:72
#24 0x0000000100365d71 in File.init(with:) at /Users/yeatse/Developer/Repo/mocha/Shared/IO/File.swift:60
#25 0x00000001002f6d07 in ContentView.body.getter at /Users/yeatse/Developer/Repo/mocha/Shared/ContentView.swift:44
#26 0x00000001002f95c9 in protocol witness for View.body.getter in conformance ContentView ()
#27 0x00007ff90e9f9b6a in partial apply for closure #1 in ViewBodyAccessor.updateBody(of:changed:) ()
#28 0x00007ff90ed8732d in closure #1 in BodyAccessor.setBody(_:) ()
#29 0x00007ff90e9f9a8d in ViewBodyAccessor.updateBody(of:changed:) ()
#30 0x00007ff90ed878d7 in DynamicBody.updateValue() ()
#31 0x00007ff90e893721 in partial apply for implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<τ_0_0>(_:) ()
#32 0x00007ff90f5cc32d in AG::Graph::UpdateStack::update() ()
#33 0x00007ff90f5cc92d in AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) ()
#34 0x00007ff90f5d6e28 in AG::Subgraph::update(unsigned int) ()
#35 0x00007ff90f35397e in GraphHost.flushTransactions() ()
#36 0x00007ff90f35477d in closure #1 in closure #1 in closure #1 in GraphHost.asyncTransaction<τ_0_0>(_:mutation:style:mayDeferUpdate:) ()
#37 0x00007ff90f354160 in specialized thunk for @callee_guaranteed (@guaranteed GraphHost) -> () ()
#38 0x00007ff90e9d5864 in partial apply for closure #1 in ViewGraphDelegate.updateGraph<τ_0_0>(body:) ()
#39 0x00007ff90f1bc51e in closure #1 in ViewRendererHost.updateViewGraph<τ_0_0>(body:) ()
#40 0x00007ff90f1bb180 in ViewRendererHost.updateViewGraph<τ_0_0>(body:) ()
#41 0x00007ff90f1c98ad in protocol witness for ViewGraphDelegate.updateViewGraph<τ_0_0>(body:) in conformance NSHostingView<τ_1_0> ()
#42 0x00007ff90e9ced4c in ViewGraphDelegate.updateGraph<τ_0_0>(body:) ()
#43 0x00007ff90e9d57e9 in protocol witness for GraphDelegate.updateGraph<τ_0_0>(body:) in conformance NSHostingView<τ_1_0> ()
#44 0x00007ff90f354759 in closure #1 in GraphHost.init(data:) ()
#45 0x00007ff90f3555c0 in partial apply for closure #1 in closure #1 in GraphHost.asyncTransaction<τ_0_0>(_:mutation:style:mayDeferUpdate:) ()
#46 0x00007ff90e9d7047 in thunk for @escaping @callee_guaranteed () -> () ()
#47 0x00007ff90f239d13 in partial apply for thunk for @escaping @callee_guaranteed () -> () ()
#48 0x00007ff90f2375fd in static NSRunLoop.flushObservers() ()
#49 0x00007ff90f239c90 in closure #1 in closure #1 in static NSRunLoop.addObserver(_:) ()
#50 0x00007ff90f2338b2 in specialized thunk for @callee_guaranteed () -> (@error @owned Error) ()
#51 0x00007ff818c3de6c in autoreleasepool<τ_0_0>(invoking:) ()
#52 0x00007ff90f239c7f in closure #1 in static NSRunLoop.addObserver(_:) ()
#53 0x00007ff90f239cbd in @objc closure #1 in static NSRunLoop.addObserver(_:) ()
#54 0x00007ff803fb5cb7 in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#55 0x00007ff803fb5b54 in __CFRunLoopDoObservers ()
#56 0x00007ff803fb4655 in CFRunLoopRunSpecific ()
#57 0x00007ff80cbf14f1 in RunCurrentEventLoopInMode ()
#58 0x00007ff80cbf1247 in ReceiveNextEventCommon ()
#59 0x00007ff80cbf0fe5 in _BlockUntilNextEventMatchingListInModeWithFilter ()
#60 0x00007ff8069e3d88 in _DPSNextEvent ()
#61 0x00007ff8069e23f4 in -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] ()
#62 0x00007ff806be6e6c in -[NSWindow(NSEventRouting) trackEventsMatchingMask:timeout:mode:handler:] ()
#63 0x00007ff80b523ee6 in -[NSRemoteView _beginTrackingLoop:reply:] ()
#64 0x00007ff80b526c32 in -[NSRemoteViewMarshal beginTrackingLoop:reply:] ()
#65 0x00007ff803f9a27c in __invoking___ ()
#66 0x00007ff803f9a115 in -[NSInvocation invoke] ()
#67 0x00007ff80b4bd1b9 in __deferNSXPCInvocationOntoMainThread_block_invoke ()
#68 0x00007ff80b4b0550 in __wrapBlockWithVoucher_block_invoke ()
#69 0x00007ff80b4b01d8 in __deferBlockOntoMainThread_block_invoke_2 ()
#70 0x00007ff803fb64a3 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ ()
#71 0x00007ff803fb6353 in __CFRunLoopDoBlocks ()
#72 0x00007ff803fb56b8 in __CFRunLoopRun ()
#73 0x00007ff803fb45dd in CFRunLoopRunSpecific ()
#74 0x00007ff80cbf14f1 in RunCurrentEventLoopInMode ()
#75 0x00007ff80cbf1247 in ReceiveNextEventCommon ()
#76 0x00007ff80cbf0fe5 in _BlockUntilNextEventMatchingListInModeWithFilter ()
#77 0x00007ff8069e3d88 in _DPSNextEvent ()
#78 0x00007ff8069e23f4 in -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] ()
#79 0x00007ff8069d4919 in -[NSApplication run] ()
#80 0x00007ff8069a87b7 in NSApplicationMain ()
#81 0x00007ff90e7dfd3f in specialized runApp(_:) ()
#82 0x00007ff90f1fec84 in runApp<τ_0_0>(_:) ()
#83 0x00007ff90ed0691f in static App.main() ()
#84 0x000000010034a23e in static mochaApp.$main() at /Users/yeatse/Developer/Repo/mocha/Shared/mochaApp.swift:10
#85 0x000000010034a2b9 in main ()
#86 0x0000000107b434fe in start ()
Problem disappeared after creating a piece of buffer while casting data to integers, but I'm not sure if it is the right way to fix this:
if self.count == 4 {
return Swift.UInt64(self.UInt32)
} else if self.count == 8 {
- return self.withUnsafeBytes { $0.load(as: Swift.UInt64.self) }
+ var buffer = Data(count: 8)
+ buffer.withUnsafeMutableBytes { headerPtr in
+ self.withUnsafeBytes { headerPtr.copyMemory(from: $0) }
+ }
+ return buffer.withUnsafeBytes { $0.load(as: Swift.UInt64.self) }