swift: Runtime Crash at "__swift_instantiateConcreteTypeFromMangledName"

Description

DiscordBM crashes at __swift_instantiateConcreteTypeFromMangledName.

Reproduction

  • Clone DiscordBM.
  • On CLI run BOT_TOKEN=aaaaaa swift test --filter IntegrationTests.DiscordClientTests.testGateway.
  • Or on Xcode add BOT_TOKEN as an env var with any value, and run the testGateway() test.

Stack dump

<kbd> Screenshot 2024-06-11 at 10 31 57 PM </kbd>

Expected behavior

No crash.

Environment

  • macOS 14 + Swift 5.10 + Xcode 15.4.
  • macOS 15 + Swift 6 + Xcode 16.

Not reproducible on Linux.

Additional information

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 1
  • Comments: 30 (9 by maintainers)

Most upvoted comments

@mikeash I downgraded to Xcode 15.3 and I verified the with otool -l that the @rpath is now correct but I am still getting a crash:

8 libswiftCore.dylib 0x00007fff2cc6c2dd swift::Demangle::__runtime::Demangler::demangleSymbolicReference(unsigned char) + 141
9 libswiftCore.dylib 0x00007fff2cc692a8 swift::Demangle::__runtime::Demangler::demangleType(__swift::__runtime::llvm::StringRef, std::__1::function<swift::Demangle::__runtime::Node* (swift::Demangle::__runtime::SymbolicReferenceKind, swift::Demangle::__runtime::Directness, int, void const*)>) + 168
10 libswiftCore.dylib 0x00007fff2cc4f5a4 swift_getTypeByMangledNameImpl(swift::MetadataRequest, __swift::__runtime::llvm::StringRef, void const* const*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) + 516
11 libswiftCore.dylib 0x00007fff2cc4cd6d swift::swift_getTypeByMangledName(swift::MetadataRequest, __swift::__runtime::llvm::StringRef, void const* const*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) + 477
12 libswiftCore.dylib 0x00007fff2cc4cf9b swift_getTypeByMangledNameInContext + 171
__swift_instantiateConcreteTypeFromMangledName (in HSTracker) (/<compiler-generated>:0)
closure #1 in BattlegroundsSession.battlegroundsGameMode.setter (in HSTracker) (<stdin>:0)
thunk for @escaping @callee_guaranteed () -> () (in HSTracker) (/<compiler-generated>:0)

Here’s the output of otool -l:

Load command 49
          cmd LC_LOAD_WEAK_DYLIB
      cmdsize 64
         name @rpath/libswift_Concurrency.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 0.0.0
compatibility version 1.0.0

Any ideas of what else might be wrong? I don’t know how to confirm I have fixed the crash without access to a system with the issue

I believe this could be the same issue: https://github.com/apple/swift/issues/74333