swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.3k stars 10.34k forks source link

[SR-12423] App built in release mode w/ 5.2/Xcode 11.14 segfaults #54862

Open swift-ci opened 4 years ago

swift-ci commented 4 years ago
Previous ID SR-12423
Radar rdar://problem/60923904
Original Reporter helge (JIRA User)
Type Bug
Environment Mac OS X 10.15.4 (19E266) Xcode Version 11.4 (11E146)
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 4dd2006f4b10b1dff9a4b2f7f9a6ee61

Issue Description:

Debug works fine, so probably an optimiser issue.

backtrace within Xcode

Marzipan was compiled with optimization - stepping may behave oddly; variables may not be available.
* thread #​1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x20)
    frame #&#8203;0: 0x00007fff6df81b90 libswiftCore.dylib`Swift.(_stringCompareFastUTF8Abnormal in _835F230159459CFFE280B5F8E69D8077)(_: Swift.UnsafeBufferPointer<Swift.UInt8>, _: Swift.UnsafeBufferPointer<Swift.UInt8>, expecting: Swift._StringComparisonResult) -> Swift.Bool + 48
    frame #&#8203;1: 0x00000001006f812b Marzipan`specialized thunk for @escaping @callee_guaranteed (@guaranteed A, @guaranteed A) -> (@unowned Bool) [inlined] MMM.(compareConversation in _24F12AD896879B222B96E7000F788E5D)(lhs: PPP, rhs: PPP) -> Swift.Bool at <compiler-generated>:0 [opt]
    frame #&#8203;2: 0x00000001006f8120 Marzipan`specialized thunk for @escaping @callee_guaranteed (@guaranteed A, @guaranteed A) -> (@unowned Bool) [inlined] function signature specialization <Arg[2] = [Constant Propagated Function : MMM.(compareConversation in _24F12AD896879B222B96E7000F788E5D)(lhs: PPP, rhs: PPP) -> Swift.Bool]> of reabstraction thunk helper <A where A: PPP, A: Swift.Equatable> from @escaping @callee_guaranteed (@guaranteed PPP, @guaranteed PPP) -> (@unowned Swift.Bool) to @escaping @callee_guaranteed (@guaranteed A, @guaranteed A) -> (@unowned Swift.Bool) at <compiler-generated>:0 [opt]
    frame #&#8203;3: 0x00000001006f8120 Marzipan`specialized thunk for @escaping @callee_guaranteed (@guaranteed A, @guaranteed A) -> (@unowned Bool) at <compiler-generated>:0 [opt]
    frame #&#8203;4: 0x000000010069c7eb Marzipan`specialized MutableCollection<>._insertionSort(within:sortedEnd:by:) at <compiler-generated>:0 [opt]
    frame #&#8203;5: 0x0000000100699279 Marzipan`merged generic specialization <XXX> of Swift.UnsafeMutableBufferPointer._stableSortImpl(by: (A, A) throws -> Swift.Bool) throws -> () + 169
    frame #&#8203;6: 0x0000000100694547 Marzipan`specialized MutableCollection<>.sort(by:) [inlined] generic specialization <Swift.ContiguousArray<XXX>> of closure #&#8203;1 (inout Swift.UnsafeMutableBufferPointer<A.Swift.Sequence.Element>) throws -> () in (extension in Swift):Swift.MutableCollection< where A: Swift.RandomAccessCollection>.sort(by: (A.Swift.Sequence.Element, A.Swift.Sequence.Element) throws -> Swift.Bool) throws -> () at <compiler-generated>:0 [opt]
    frame #&#8203;7: 0x000000010069451d Marzipan`specialized MutableCollection<>.sort(by:) [inlined] inlined generic function <Swift.ContiguousArray<XXX>> of reabstraction thunk helper <A where A: Swift.MutableCollection, A: Swift.RandomAccessCollection> from @callee_guaranteed (@inout Swift.UnsafeMutableBufferPointer<A.Swift.Sequence.Element>) -> (@error @owned Swift.Error) to @escaping @callee_guaranteed (@inout Swift.UnsafeMutableBufferPointer<A.Swift.Sequence.Element>) -> (@out (), @error @owned Swift.Error) at <compiler-generated>:0 [opt]
    frame #&#8203;8: 0x000000010069451d Marzipan`specialized MutableCollection<>.sort(by:) [inlined] generic specialization <XXX, ()> of closure #&#8203;1 (inout Swift.UnsafeMutableBufferPointer<A>) throws -> A1 in Swift.ContiguousArray._withUnsafeMutableBufferPointerIfSupported<A>((inout Swift.UnsafeMutableBufferPointer<A>) throws -> A1) throws -> Swift.Optional<A1> at <compiler-generated>:0 [opt]
    frame #&#8203;9: 0x000000010069451d Marzipan`specialized MutableCollection<>.sort(by:) [inlined] generic specialization <XXX, ()> of Swift.ContiguousArray._withUnsafeMutableBufferPointerIfSupported<A>((inout Swift.UnsafeMutableBufferPointer<A>) throws -> A1) throws -> Swift.Optional<A1> at <compiler-generated>:0 [opt]
    frame #&#8203;10: 0x000000010069451d Marzipan`specialized MutableCollection<>.sort(by:) [inlined] inlined generic function <XXX, ()> of protocol witness for Swift.MutableCollection._withUnsafeMutableBufferPointerIfSupported<A>((inout Swift.UnsafeMutableBufferPointer<A.Element>) throws -> A1) throws -> Swift.Optional<A1> in conformance Swift.ContiguousArray<A> : Swift.MutableCollection in Swift at <compiler-generated>:0 [opt]
    frame #&#8203;11: 0x000000010069451d Marzipan`specialized MutableCollection<>.sort(by:) at <compiler-generated>:0 [opt]
    frame #&#8203;12: 0x000000010068ff62 Marzipan`specialized AAA.arrangeObjects() [inlined] generic specialization <Swift.Dictionary<YYY, XXX>.Values> of (extension in Swift):Swift.Sequence.sorted(by: (A.Element, A.Element) throws -> Swift.Bool) throws -> Swift.Array<A.Element> at <compiler-generated>:0 [opt]

relevant code section

  private func arrangeObjects() {
    assertMainQueue()
    matches.removeAll()

    guard let matchPrefix = matchPrefix else {
      if arrangedObjects.isEmpty { return }
      arrangedObjects.removeAll()
      return emit()
    }

    if matchPrefix.isEmpty {
      if let sort = sortFunction {
        arrangedObjects = allObjects.values.sorted(by: sort)
      }...

same machine, app crash report preamble


Path:                  /Applications/Marzipan.app/Contents/MacOS/Marzipan
Identifier:            de.zeezide.swift.see1.marzipan
Version:               0.5 (37)
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           Marzipan [9811]
User ID:               501

Date/Time:             2020-03-26 17:07:47.211 +0100
OS Version:            Mac OS X 10.15.4 (19E266)
Report Version:        12
Bridge OS Version:     4.4 (17P4263)
Anonymous UUID:        3D9A839B-4E7E-4342-4336-BCEB6A848EDD

Time Awake Since Boot: 95000 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000020
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [9811]
jckarter commented 4 years ago

@swift-ci create

swift-ci commented 4 years ago

Comment by Helge Heß (JIRA)

I managed to avoid the crash by slapping an `@_optimized(none)` at the initializer which uses the sort function:

public final class XYZBlubLiveQuery
                     <ValueType: PPP & Equatable>
                   : XYZPrefixLiveQuery<ValueType>
{
  @_optimize(none) // https://bugs.swift.org/browse/SR-12423
  internal init(initialState state: [ SomeIDStruct : ValueType ]) {
    super.init(initialState: state, matchPrefix: "",
               sortFunction: compareConversation)
  }

the `compareConversation` function is what is used in the `arrangeObjects` shown above as `sort`.

eeckstein commented 4 years ago

helge (JIRA User) Is it possible that you attach a reduced test case so that we can reproduce the issue?

swift-ci commented 4 years ago

Comment by Helge Heß (JIRA)

That stuff is spanning things from at least 3 modules, it'll be a significant amount of work to extract that. I'll see whether I can find the time, but I can't promise that.

Vaida12345 commented 2 months ago

I have encountered the same issue, but have been unable to determine the exact cause of issue.

Here are the details:

libswiftCore.dylib`Swift._stringCompareFastUTF8Abnormal(_: Swift.UnsafeBufferPointer<Swift.UInt8>, _: Swift.UnsafeBufferPointer<Swift.UInt8>, expecting: Swift._StringComparisonResult) -> Swift.Bool:
    0x1a29ac474 <+0>:   pacibsp 
    0x1a29ac478 <+4>:   sub    sp, sp, #0x70
    0x1a29ac47c <+8>:   stp    x28, x27, [sp, #0x10]
    0x1a29ac480 <+12>:  stp    x26, x25, [sp, #0x20]
    0x1a29ac484 <+16>:  stp    x24, x23, [sp, #0x30]
    0x1a29ac488 <+20>:  stp    x22, x21, [sp, #0x40]
    0x1a29ac48c <+24>:  stp    x20, x19, [sp, #0x50]
    0x1a29ac490 <+28>:  stp    x29, x30, [sp, #0x60]
    0x1a29ac494 <+32>:  add    x29, sp, #0x60
    0x1a29ac498 <+36>:  mov    x20, x3
    0x1a29ac49c <+40>:  mov    x22, x1
    0x1a29ac4a0 <+44>:  and    w19, w4, #0x1
    0x1a29ac4a4 <+48>:  cmp    x3, x1
    0x1a29ac4a8 <+52>:  csel   x8, x3, x1, lt
    0x1a29ac4ac <+56>:  cmp    x8, #0x1
    0x1a29ac4b0 <+60>:  b.lt   0x1a29ac4dc               ; <+104>
    0x1a29ac4b4 <+64>:  mov    x21, x2
    0x1a29ac4b8 <+68>:  mov    x23, x0
    0x1a29ac4bc <+72>:  mov    x24, #0x0                 ; =0 
->  0x1a29ac4c0 <+76>:  ldrb   w9, [x23, x24]
    0x1a29ac4c4 <+80>:  ldrb   w10, [x21, x24]
    0x1a29ac4c8 <+84>:  cmp    w9, w10
    0x1a29ac4cc <+88>:  b.ne   0x1a29ac4f4               ; <+128>
    0x1a29ac4d0 <+92>:  add    x24, x24, #0x1
    0x1a29ac4d4 <+96>:  cmp    x8, x24
    0x1a29ac4d8 <+100>: b.ne   0x1a29ac4c0               ; <+76>
    0x1a29ac4dc <+104>: cmp    x22, x20
    0x1a29ac4e0 <+108>: cset   w8, lt
    0x1a29ac4e4 <+112>: cset   w9, eq
    0x1a29ac4e8 <+116>: cmp    w19, #0x0
    0x1a29ac4ec <+120>: csel   w0, w8, w9, ne
    0x1a29ac4f0 <+124>: b      0x1a29ac668               ; <+500>
    0x1a29ac4f4 <+128>: mov    x26, x22
    0x1a29ac4f8 <+132>: cmp    x22, x24
    0x1a29ac4fc <+136>: b.eq   0x1a29ac51c               ; <+168>
    0x1a29ac500 <+140>: mov    x8, x24
    0x1a29ac504 <+144>: ldrb   w9, [x23, x8]
    0x1a29ac508 <+148>: and    w9, w9, #0xc0
    0x1a29ac50c <+152>: sub    x8, x8, #0x1
    0x1a29ac510 <+156>: cmp    w9, #0x80
    0x1a29ac514 <+160>: b.eq   0x1a29ac504               ; <+144>
    0x1a29ac518 <+164>: add    x26, x8, #0x1
    0x1a29ac51c <+168>: mov    x0, x23
    0x1a29ac520 <+172>: mov    x2, x26
    0x1a29ac524 <+176>: bl     0x1a293ba78               ; Swift._decodeScalar(_: Swift.UnsafeBufferPointer<Swift.UInt8>, startingAt: Swift.Int) -> (Swift.Unicode.Scalar, scalarLength: Swift.Int)
    0x1a29ac528 <+180>: mov    x25, x0
    0x1a29ac52c <+184>: mov    x28, x1
    0x1a29ac530 <+188>: mov    x0, x21
    0x1a29ac534 <+192>: mov    x2, x26
    0x1a29ac538 <+196>: bl     0x1a293ba78               ; Swift._decodeScalar(_: Swift.UnsafeBufferPointer<Swift.UInt8>, startingAt: Swift.Int) -> (Swift.Unicode.Scalar, scalarLength: Swift.Int)
    0x1a29ac53c <+200>: mov    x27, x0
    0x1a29ac540 <+204>: str    x1, [sp, #0x8]
    0x1a29ac544 <+208>: cmp    w25, #0x300
    0x1a29ac548 <+212>: b.lo   0x1a29ac55c               ; <+232>
    0x1a29ac54c <+216>: mov    x0, x25
    0x1a29ac550 <+220>: bl     0x1a2c11700               ; _swift_stdlib_getNormData
    0x1a29ac554 <+224>: cmp    w0, #0x1
    0x1a29ac558 <+228>: b.hi   0x1a29ac5b0               ; <+316>
    0x1a29ac55c <+232>: cmp    w27, #0x300
    0x1a29ac560 <+236>: b.lo   0x1a29ac574               ; <+256>
    0x1a29ac564 <+240>: mov    x0, x27
    0x1a29ac568 <+244>: bl     0x1a2c11700               ; _swift_stdlib_getNormData
    0x1a29ac56c <+248>: cmp    w0, #0x1
    0x1a29ac570 <+252>: b.hi   0x1a29ac5b0               ; <+316>
    0x1a29ac574 <+256>: add    x0, x28, x26
    0x1a29ac578 <+260>: mov    x1, x23
    0x1a29ac57c <+264>: mov    x2, x22
    0x1a29ac580 <+268>: bl     0x1a29ac6b0               ; Swift.UnsafeBufferPointer<τ_0_0 where τ_0_0 == Swift.UInt8>.hasNormalizationBoundary(before: Swift.Int) -> Swift.Bool
    0x1a29ac584 <+272>: tbz    w0, #0x0, 0x1a29ac5b0     ; <+316>
    0x1a29ac588 <+276>: ldr    x8, [sp, #0x8]
    0x1a29ac58c <+280>: add    x0, x8, x26
    0x1a29ac590 <+284>: mov    x1, x21
    0x1a29ac594 <+288>: mov    x2, x20
    0x1a29ac598 <+292>: bl     0x1a29ac6b0               ; Swift.UnsafeBufferPointer<τ_0_0 where τ_0_0 == Swift.UInt8>.hasNormalizationBoundary(before: Swift.Int) -> Swift.Bool
    0x1a29ac59c <+296>: tbz    w0, #0x0, 0x1a29ac5b0     ; <+316>
    0x1a29ac5a0 <+300>: cmp    w19, #0x0
    0x1a29ac5a4 <+304>: ccmp   w25, w27, #0x2, ne
    0x1a29ac5a8 <+308>: cset   w0, lo
    0x1a29ac5ac <+312>: b      0x1a29ac668               ; <+500>
    0x1a29ac5b0 <+316>: mov    x0, x23
    0x1a29ac5b4 <+320>: mov    x1, x22
    0x1a29ac5b8 <+324>: mov    x2, x24
    0x1a29ac5bc <+328>: bl     0x1a29ac718               ; Swift._findBoundary(_: Swift.UnsafeBufferPointer<Swift.UInt8>, before: Swift.Int) -> Swift.Int
    0x1a29ac5c0 <+332>: mov    x25, x0
    0x1a29ac5c4 <+336>: mov    x0, x21
    0x1a29ac5c8 <+340>: mov    x1, x20
    0x1a29ac5cc <+344>: mov    x2, x24
    0x1a29ac5d0 <+348>: bl     0x1a29ac718               ; Swift._findBoundary(_: Swift.UnsafeBufferPointer<Swift.UInt8>, before: Swift.Int) -> Swift.Int
    0x1a29ac5d4 <+352>: cmp    x0, x25
    0x1a29ac5d8 <+356>: csel   x24, x0, x25, lt
    0x1a29ac5dc <+360>: mov    x0, x24
    0x1a29ac5e0 <+364>: mov    x1, x23
    0x1a29ac5e4 <+368>: mov    x2, x22
    0x1a29ac5e8 <+372>: bl     0x1a28e0df8               ; merged generic specialization <Swift.UnsafeBufferPointer<Swift.UInt8>, Swift.PartialRangeFrom<Swift.Int>> of Swift.Collection.subscript.getter : <τ_0_0 where τ_1_0: Swift.RangeExpression, τ_0_0.Index == τ_1_0.Bound>(τ_1_0) -> τ_0_0.SubSequence
    0x1a29ac5ec <+376>: bl     0x1a28e103c               ; merged generic specialization <Swift.UInt8> of Swift.UnsafeBufferPointer.init(rebasing: Swift.Slice<Swift.UnsafeBufferPointer<τ_0_0>>) -> Swift.UnsafeBufferPointer<τ_0_0>
    0x1a29ac5f0 <+380>: mov    x22, x0
    0x1a29ac5f4 <+384>: mov    x23, x1
    0x1a29ac5f8 <+388>: mov    x0, x24
    0x1a29ac5fc <+392>: mov    x1, x21
    0x1a29ac600 <+396>: mov    x2, x20
    0x1a29ac604 <+400>: bl     0x1a28e0df8               ; merged generic specialization <Swift.UnsafeBufferPointer<Swift.UInt8>, Swift.PartialRangeFrom<Swift.Int>> of Swift.Collection.subscript.getter : <τ_0_0 where τ_1_0: Swift.RangeExpression, τ_0_0.Index == τ_1_0.Bound>(τ_1_0) -> τ_0_0.SubSequence
    0x1a29ac608 <+404>: bl     0x1a28e103c               ; merged generic specialization <Swift.UInt8> of Swift.UnsafeBufferPointer.init(rebasing: Swift.Slice<Swift.UnsafeBufferPointer<τ_0_0>>) -> Swift.UnsafeBufferPointer<τ_0_0>
    0x1a29ac60c <+408>: orr    x5, x23, #0x1000000000000000
    0x1a29ac610 <+412>: mov    x9, #0x7fffffffffffffe0   ; =9223372036854775776 
    0x1a29ac614 <+416>: add    x8, x22, x9
    0x1a29ac618 <+420>: orr    x6, x8, #0x8000000000000000
    0x1a29ac61c <+424>: ubfx   x10, x8, #56, #4
    0x1a29ac620 <+428>: and    x11, x23, #0xffffffffffff
    0x1a29ac624 <+432>: tst    x8, #0x2000000000000000
    0x1a29ac628 <+436>: csel   x10, x11, x10, eq
    0x1a29ac62c <+440>: orr    x8, x1, #0x1000000000000000
    0x1a29ac630 <+444>: add    x11, x0, x9
    0x1a29ac634 <+448>: orr    x9, x11, #0x8000000000000000
    0x1a29ac638 <+452>: ubfx   x12, x11, #56, #4
    0x1a29ac63c <+456>: and    x13, x1, #0xffffffffffff
    0x1a29ac640 <+460>: tst    x11, #0x2000000000000000
    0x1a29ac644 <+464>: csel   x3, x13, x12, eq
    0x1a29ac648 <+468>: str    x10, [sp]
    0x1a29ac64c <+472>: mov    x0, x8
    0x1a29ac650 <+476>: mov    x1, x9
    0x1a29ac654 <+480>: mov    x2, #0x0                  ; =0 
    0x1a29ac658 <+484>: mov    x4, x19
    0x1a29ac65c <+488>: mov    x7, #0x0                  ; =0 
    0x1a29ac660 <+492>: bl     0x1a29ac888               ; Swift._StringGutsSlice.compare(with: Swift._StringGutsSlice, expecting: Swift._StringComparisonResult) -> Swift.Bool
    0x1a29ac664 <+496>: and    w0, w0, #0x1
    0x1a29ac668 <+500>: ldp    x29, x30, [sp, #0x60]
    0x1a29ac66c <+504>: ldp    x20, x19, [sp, #0x50]
    0x1a29ac670 <+508>: ldp    x22, x21, [sp, #0x40]
    0x1a29ac674 <+512>: ldp    x24, x23, [sp, #0x30]
    0x1a29ac678 <+516>: ldp    x26, x25, [sp, #0x20]
    0x1a29ac67c <+520>: ldp    x28, x27, [sp, #0x10]
    0x1a29ac680 <+524>: add    sp, sp, #0x70
    0x1a29ac684 <+528>: retab  

Backtrace:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x27117c000)
  * frame #0: 0x00000001a29ac4c0 libswiftCore.dylib`Swift._stringCompareFastUTF8Abnormal(_: Swift.UnsafeBufferPointer<Swift.UInt8>, _: Swift.UnsafeBufferPointer<Swift.UInt8>, expecting: Swift._StringComparisonResult) -> Swift.Bool + 76
    frame #1: 0x00000001c016c488 AttributeGraph`AGDispatchEquatable + 24
    frame #2: 0x00000001c0152598 AttributeGraph`AG::LayoutDescriptor::Compare::operator()(unsigned char const*, unsigned char const*, unsigned char const*, unsigned long, unsigned int) + 1608
    frame #3: 0x00000001c0152958 AttributeGraph`AG::LayoutDescriptor::compare(unsigned char const*, unsigned char const*, unsigned char const*, unsigned long, unsigned int) + 96
    frame #4: 0x00000001c0152050 AttributeGraph`AG::LayoutDescriptor::Compare::operator()(unsigned char const*, unsigned char const*, unsigned char const*, unsigned long, unsigned int) + 256
    frame #5: 0x00000001c0152958 AttributeGraph`AG::LayoutDescriptor::compare(unsigned char const*, unsigned char const*, unsigned char const*, unsigned long, unsigned int) + 96
    frame #6: 0x00000001bf86d85c SwiftUI`___lldb_unnamed_symbol208481 + 44
    frame #7: 0x00000001a291a0f0 libswiftCore.dylib`Swift.withUnsafePointer<τ_0_0, τ_0_1>(to: τ_0_0, _: (Swift.UnsafePointer<τ_0_0>) throws -> τ_0_1) throws -> τ_0_1 + 28
    frame #8: 0x00000001bf86d728 SwiftUI`___lldb_unnamed_symbol208477 + 64
    frame #9: 0x00000001bf26181c SwiftUI`___lldb_unnamed_symbol168022 + 24
    frame #10: 0x00000001a291a0f0 libswiftCore.dylib`Swift.withUnsafePointer<τ_0_0, τ_0_1>(to: τ_0_0, _: (Swift.UnsafePointer<τ_0_0>) throws -> τ_0_1) throws -> τ_0_1 + 28
    frame #11: 0x00000001bf26090c SwiftUI`___lldb_unnamed_symbol167974 + 192
    frame #12: 0x00000001bf2609d8 SwiftUI`___lldb_unnamed_symbol167980 + 56
    frame #13: 0x00000001bf25f8d8 SwiftUI`___lldb_unnamed_symbol167925 + 408
    frame #14: 0x00000001bf25efa8 SwiftUI`static SwiftUI.AnyLocation.== infix(SwiftUI.AnyLocation<τ_0_0>, SwiftUI.AnyLocation<τ_0_0>) -> Swift.Bool + 52
    frame #15: 0x00000001bfc0cc00 SwiftUI`___lldb_unnamed_symbol231805 + 68
    frame #16: 0x00000001bf25f8d8 SwiftUI`___lldb_unnamed_symbol167925 + 408
    frame #17: 0x00000001bf25efa8 SwiftUI`static SwiftUI.AnyLocation.== infix(SwiftUI.AnyLocation<τ_0_0>, SwiftUI.AnyLocation<τ_0_0>) -> Swift.Bool + 52
    frame #18: 0x00000001bf25f00c SwiftUI`___lldb_unnamed_symbol167916 + 24
    frame #19: 0x00000001c016c488 AttributeGraph`AGDispatchEquatable + 24
    frame #20: 0x00000001c0152598 AttributeGraph`AG::LayoutDescriptor::Compare::operator()(unsigned char const*, unsigned char const*, unsigned char const*, unsigned long, unsigned int) + 1608
    frame #21: 0x00000001c0152200 AttributeGraph`AG::LayoutDescriptor::Compare::operator()(unsigned char const*, unsigned char const*, unsigned char const*, unsigned long, unsigned int) + 688
    frame #22: 0x00000001c0152200 AttributeGraph`AG::LayoutDescriptor::Compare::operator()(unsigned char const*, unsigned char const*, unsigned char const*, unsigned long, unsigned int) + 688
    frame #23: 0x00000001c0152958 AttributeGraph`AG::LayoutDescriptor::compare(unsigned char const*, unsigned char const*, unsigned char const*, unsigned long, unsigned int) + 96
    frame #24: 0x00000001c0161488 AttributeGraph`AGGraphSetOutputValue + 268
    frame #25: 0x00000001bfb6e91c SwiftUI`___lldb_unnamed_symbol229170 + 72
    frame #26: 0x00000001bebfbbac SwiftUI`___lldb_unnamed_symbol124717 + 20
    frame #27: 0x00000001a291a118 libswiftCore.dylib`Swift.withUnsafePointer<τ_0_0, τ_0_1>(to: inout τ_0_0, _: (Swift.UnsafePointer<τ_0_0>) throws -> τ_0_1) throws -> τ_0_1 + 28
    frame #28: 0x00000001bebeb5f0 SwiftUI`___lldb_unnamed_symbol123933 + 1252
    frame #29: 0x00000001bfb6fb70 SwiftUI`___lldb_unnamed_symbol229195 + 584
    frame #30: 0x00000001bfb6f6a4 SwiftUI`___lldb_unnamed_symbol229194 + 712
    frame #31: 0x00000001be5495b4 SwiftUI`___lldb_unnamed_symbol82518 + 32
    frame #32: 0x00000001c013f5c0 AttributeGraph`AG::Graph::UpdateStack::update() + 512
    frame #33: 0x00000001c013fdfc AttributeGraph`AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 424
    frame #34: 0x00000001c014e7ac AttributeGraph`AG::Subgraph::update(unsigned int) + 848
    frame #35: 0x00000001bfa40650 SwiftUI`___lldb_unnamed_symbol220506 + 404
    frame #36: 0x00000001bfb051e4 SwiftUI`___lldb_unnamed_symbol225799 + 328
    frame #37: 0x00000001bfb020d8 SwiftUI`___lldb_unnamed_symbol225643 + 384
    frame #38: 0x00000001bf1b8a54 SwiftUI`___lldb_unnamed_symbol163129 + 200
    frame #39: 0x00000001bf1c3b84 SwiftUI`___lldb_unnamed_symbol163489 + 28
    frame #40: 0x00000001bf1b8ee0 SwiftUI`___lldb_unnamed_symbol163132 + 44
    frame #41: 0x0000000196433848 AppKit`+[NSAnimationContext runAnimationGroup:] + 56
    frame #42: 0x00000001bf1b8930 SwiftUI`___lldb_unnamed_symbol163128 + 340
    frame #43: 0x00000001bf1b8f20 SwiftUI`___lldb_unnamed_symbol163133 + 28
    frame #44: 0x0000000196ec8b58 AppKit`___NSViewLayout_block_invoke + 592
    frame #45: 0x000000019645e8a4 AppKit`NSPerformVisuallyAtomicChange + 108
    frame #46: 0x0000000196462fe4 AppKit`_NSViewLayout + 96
    frame #47: 0x0000000196ebf204 AppKit`__36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 364
    frame #48: 0x000000019645e8a4 AppKit`NSPerformVisuallyAtomicChange + 108
    frame #49: 0x0000000196462f78 AppKit`-[NSView _layoutSubtreeWithOldSize:] + 100
    frame #50: 0x0000000196ebf348 AppKit`__36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 688
    frame #51: 0x000000019645e8a4 AppKit`NSPerformVisuallyAtomicChange + 108
    frame #52: 0x0000000196462f78 AppKit`-[NSView _layoutSubtreeWithOldSize:] + 100
    frame #53: 0x0000000196ebfcec AppKit`__56-[NSView _layoutSubtreeIfNeededAndAllowTemporaryEngine:]_block_invoke + 796
    frame #54: 0x000000019645e8a4 AppKit`NSPerformVisuallyAtomicChange + 108
    frame #55: 0x0000000196462b38 AppKit`-[NSView _layoutSubtreeIfNeededAndAllowTemporaryEngine:] + 100
    frame #56: 0x000000019645e8a4 AppKit`NSPerformVisuallyAtomicChange + 108
    frame #57: 0x0000000196462ac8 AppKit`-[NSView layoutSubtreeIfNeeded] + 96
    frame #58: 0x000000019716a520 AppKit`-[NSWindow(NSConstraintBasedLayoutInternal) _layoutViewTree] + 104
    frame #59: 0x000000019716a6a8 AppKit`-[NSWindow(NSConstraintBasedLayoutInternal) layoutIfNeeded] + 240
    frame #60: 0x00000001964c16b4 AppKit`__NSWindowGetDisplayCycleObserverForLayout_block_invoke + 364
    frame #61: 0x00000001964c0c4c AppKit`NSDisplayCycleObserverInvoke + 168
    frame #62: 0x00000001964c08a8 AppKit`NSDisplayCycleFlush + 644
    frame #63: 0x000000019adaff64 QuartzCore`CA::Transaction::run_commit_handlers(CATransactionPhase) + 120
    frame #64: 0x000000019adaed04 QuartzCore`CA::Transaction::commit() + 320
    frame #65: 0x00000001965449d0 AppKit`__62+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayLink]_block_invoke + 272
    frame #66: 0x0000000196f04208 AppKit`___NSRunLoopObserverCreateWithHandler_block_invoke + 64
    frame #67: 0x0000000192bbd87c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
    frame #68: 0x0000000192bbd768 CoreFoundation`__CFRunLoopDoObservers + 536
    frame #69: 0x0000000192bbcd94 CoreFoundation`__CFRunLoopRun + 776
    frame #70: 0x0000000192bbc434 CoreFoundation`CFRunLoopRunSpecific + 608
    frame #71: 0x000000019d36019c HIToolbox`RunCurrentEventLoopInMode + 292
    frame #72: 0x000000019d35fe2c HIToolbox`ReceiveNextEventCommon + 220
    frame #73: 0x000000019d35fd30 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 76
    frame #74: 0x000000019641bd68 AppKit`_DPSNextEvent + 660
    frame #75: 0x0000000196c11808 AppKit`-[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 700
    frame #76: 0x000000019640f09c AppKit`-[NSApplication run] + 476
    frame #77: 0x00000001963e62e0 AppKit`NSApplicationMain + 880
    frame #78: 0x00000001be55a474 SwiftUI`___lldb_unnamed_symbol83059 + 160
    frame #79: 0x00000001becc3e88 SwiftUI`___lldb_unnamed_symbol132916 + 164
    frame #80: 0x00000001bf0beeb8 SwiftUI`static SwiftUI.App.main() -> () + 132
    frame #81: 0x00000001041e7990 SpotFile`main [inlined] static SpotFile.SpotFileApp.$main() -> () at SpotFileApp.swift:0 [opt]
    frame #82: 0x00000001041e7958 SpotFile`main at SpotFileApp.swift:0 [opt]
    frame #83: 0x00000001927560e0 dyld`start + 2360
$ swift --version
swift-driver version: 1.110 Apple Swift version 6.0 (swiftlang-6.0.0.4.52 clang-1600.0.21.1.3)
Target: arm64-apple-macosx14.0
(lldb) register read x23
 x23 = 0x0000000270b6f3c8  libswift_Concurrency.dylib`protocol witness table for Swift.MainActor : Swift.Actor in Swift
AnthonyLatsis commented 2 months ago

@Vaida12345 If you can share some code for us to investigate, please open a new issue. It is very hard to debug these things with just a stack trace and some assembly around the instruction it crashed on.

tbkka commented 1 month ago

The crash in Swift._stringCompareFastUTF8Abnormal is probably resolved by https://github.com/swiftlang/swift/pull/74916

Briefly, the new @isolated(any) feature confused old runtimes which in turn led to AttributeGraph trying to use string equality to compare two things that were not in fact strings. PR #74916 changes how @isolated(any) is represented to avoid this problem.

Vaida12345 commented 1 month ago

I can no longer reproduce this issue with the latest Xcode Beta. Thank you.

$ swift --version
swift-driver version: 1.112.3 Apple Swift version 6.0 (swiftlang-6.0.0.6.8 clang-1600.0.23.1)
Target: arm64-apple-macosx14.0