Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime EXC_BAD_ACCESS crash in libswiftCore.dylib`__swift::__runtime::llvm::hash_combine<__swift::__runtime::llvm::hash_code, __swift::__runtime::llvm::StringRef>: #72979

Open
darronschall opened this issue Apr 11, 2024 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels

Comments

@darronschall
Copy link

Description

I made a small mistake that the compiler (perhaps erroneously?) accepted. The resulting binary crashes at runtime.

I've seen a few different stack dumps for this particular scenario. The one I've included is the one that happens from the simple reproducible test case. This has also manifested as:

libswiftCore.dylib`swift::ConcurrentReadableHashMap<swift::HashMapElementWrapper<(anonymous namespace)::TupleCacheEntry>, swift::Mutex>::find<(anonymous namespace)::TupleCacheEntry::Key>
libswiftCore.dylib`getCache(swift::TargetTypeContextDescriptor<swift::InProcess> const&) ()

Reproduction

import SwiftUI

struct ContentView: View {
    var body: some View {
        EmptyView()
        // NOTE: Missing leading `.` here to chain the method call; causes a runtime crash.
        fullScreenCover(isPresented: .constant(false)) {
            Text("Cover")
        }
    }
}

Stack dump

libswiftCore.dylib`__swift::__runtime::llvm::hash_combine<__swift::__runtime::llvm::hash_code, __swift::__runtime::llvm::StringRef>:
    0x19328ed2c <+0>:   sub    sp, sp, #0xc0
    0x19328ed30 <+4>:   stp    x20, x19, [sp, #0xa0]
    0x19328ed34 <+8>:   stp    x29, x30, [sp, #0xb0]
    0x19328ed38 <+12>:  add    x29, sp, #0xb0
    0x19328ed3c <+16>:  str    xzr, [sp, #0x80]
    0x19328ed40 <+20>:  movi.2d v0, #0000000000000000
    0x19328ed44 <+24>:  stp    q0, q0, [sp, #0x60]
    0x19328ed48 <+28>:  stp    q0, q0, [sp, #0x40]
    0x19328ed4c <+32>:  stp    q0, q0, [sp, #0x20]
->  0x19328ed50 <+36>:  str    q0, [sp, #0x10]
    0x19328ed54 <+40>:  adrp   x8, 365688
    0x19328ed58 <+44>:  add    x8, x8, #0xed8            ; guard variable for __swift::__runtime::llvm::hashing::detail::get_execution_seed()::seed
    0x19328ed5c <+48>:  ldaprb w8, [x8]
    0x19328ed60 <+52>:  adrp   x19, 365688
    0x19328ed64 <+56>:  tbz    w8, #0x0, 0x19328edcc     ; <+160>
    0x19328ed68 <+60>:  ldr    x8, [x19, #0xfa0]
    0x19328ed6c <+64>:  add    x9, sp, #0x10
    0x19328ed70 <+68>:  add    x19, x9, #0x40
    0x19328ed74 <+72>:  ldr    x10, [x0]
    0x19328ed78 <+76>:  orr    x20, x9, #0x8
    0x19328ed7c <+80>:  str    x8, [sp, #0x88]
    0x19328ed80 <+84>:  str    x10, [sp, #0x10]
    0x19328ed84 <+88>:  stur   xzr, [x29, #-0x18]
    0x19328ed88 <+92>:  ldp    x0, x1, [x1]
    0x19328ed8c <+96>:  bl     0x1932bced0               ; __swift::__runtime::llvm::hash_value(__swift::__runtime::llvm::StringRef)
    0x19328ed90 <+100>: mov    x4, x0
    0x19328ed94 <+104>: add    x0, sp, #0x10
    0x19328ed98 <+108>: sub    x1, x29, #0x18
    0x19328ed9c <+112>: mov    x2, x20
    0x19328eda0 <+116>: mov    x3, x19
    0x19328eda4 <+120>: bl     0x19328b29c               ; char* __swift::__runtime::llvm::hashing::detail::hash_combine_recursive_helper::combine_data<unsigned long>(unsigned long&, char*, char*, unsigned long)
    0x19328eda8 <+124>: mov    x2, x0
    0x19328edac <+128>: ldur   x1, [x29, #-0x18]
    0x19328edb0 <+132>: add    x0, sp, #0x10
    0x19328edb4 <+136>: mov    x3, x19
    0x19328edb8 <+140>: bl     0x19328b478               ; __swift::__runtime::llvm::hashing::detail::hash_combine_recursive_helper::combine(unsigned long, char*, char*)
    0x19328edbc <+144>: ldp    x29, x30, [sp, #0xb0]
    0x19328edc0 <+148>: ldp    x20, x19, [sp, #0xa0]
    0x19328edc4 <+152>: add    sp, sp, #0xc0
    0x19328edc8 <+156>: ret    
    0x19328edcc <+160>: adrp   x8, 365688
    0x19328edd0 <+164>: add    x8, x8, #0xed8            ; guard variable for __swift::__runtime::llvm::hashing::detail::get_execution_seed()::seed
    0x19328edd4 <+168>: str    x0, [sp, #0x8]
    0x19328edd8 <+172>: mov    x0, x8
    0x19328eddc <+176>: mov    x20, x1
    0x19328ede0 <+180>: bl     0x193309564               ; symbol stub for: __cxa_guard_acquire
    0x19328ede4 <+184>: mov    x1, x20
    0x19328ede8 <+188>: mov    x8, x0
    0x19328edec <+192>: ldr    x0, [sp, #0x8]
    0x19328edf0 <+196>: cbz    w8, 0x19328ed68           ; <+60>
    0x19328edf4 <+200>: adrp   x8, 365725
    0x19328edf8 <+204>: add    x8, x8, #0xb08            ; __swift::__runtime::llvm::hashing::detail::fixed_seed_override
    0x19328edfc <+208>: ldr    x8, [x8]
    0x19328ee00 <+212>: mov    x9, #0x8ccd
    0x19328ee04 <+216>: movk   x9, #0xed55, lsl #16
    0x19328ee08 <+220>: movk   x9, #0xafd7, lsl #32
    0x19328ee0c <+224>: movk   x9, #0xff51, lsl #48
    0x19328ee10 <+228>: cmp    x8, #0x0
    0x19328ee14 <+232>: csel   x8, x9, x8, eq
    0x19328ee18 <+236>: str    x8, [x19, #0xfa0]
    0x19328ee1c <+240>: adrp   x0, 365688
    0x19328ee20 <+244>: add    x0, x0, #0xed8            ; guard variable for __swift::__runtime::llvm::hashing::detail::get_execution_seed()::seed
    0x19328ee24 <+248>: bl     0x193309570               ; symbol stub for: __cxa_guard_release
    0x19328ee28 <+252>: ldr    x0, [sp, #0x8]
    0x19328ee2c <+256>: mov    x1, x20
    0x19328ee30 <+260>: b      0x19328ed68               ; <+60>

Expected behavior

Can a compiler error be generated here? It was my mistake that I accidentally forgot to use . to chain the method call.

Environment

Xcode 15.3 / Swift 5.9

Additional information

No response

@darronschall darronschall added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels labels Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant