Navigation Menu

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

[SR-14562] swiftc crash #56914

Open
swift-ci opened this issue May 2, 2021 · 2 comments
Open

[SR-14562] swiftc crash #56914

swift-ci opened this issue May 2, 2021 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented May 2, 2021

Previous ID SR-14562
Radar rdar://problem/77465731
Original Reporter helge (JIRA User)
Type Bug
Environment

M1, macOS 11.3, Xcode 12.5 RC 1

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 112e3f3d16b94b1c00cde2d29bfc6fd6

Issue Description:

Hit this while refactoring some code, no idea why and how. Was changing structs to enums and dicts to arrays and things like that 😉 A dynamic member is also involved.

Can't provided much more input, but maybe it is helpful nevertheless:

 Stored value type does not match pointer operand type!
 store %TSo13NSFileWrapperC* %167, i64* %17, align 8, !dbg !1425
 i64in function $s12XXXXXXXV20generateFileWrappersSDySSSo13NSFileWrapperCGyKF
 <unknown>:0: error: fatal error encountered during compilation; please submit a bug report ([https://swift.org/contributing/#reporting-bugs]) and include the project
 <unknown>:0: note: Broken function found, compilation aborted!
 Please submit a bug report ([https://swift.org/contributing/#reporting-bugs]) and include the project and the crash backtrace.
 Stack dump:
 0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c /Users/helge/dev/Swift/XXXXX
 1. Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)
 2. Running pass 'Module Verifier' on function '@"$s12XXXXXXXXV20generateFileWrappersSDySSSo13NSFileWrapperCGyKF"'
 0 swift-frontend 0x0000000108be85f0 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 52
 1 swift-frontend 0x0000000108be7768 llvm::sys::RunSignalHandlers() + 128
 2 swift-frontend 0x0000000108be8bc0 SignalHandler(int) + 292
 3 libsystem_platform.dylib 0x0000000184ef9c44 _sigtramp + 56
 4 libsystem_pthread.dylib 0x0000000184eaeb98 pthread_kill + 292
 5 libsystem_c.dylib 0x0000000184df7460 abort + 104
 6 swift-frontend 0x0000000104b2a85c std::__1::__throw_length_error(char const*) + 0
 7 swift-frontend 0x0000000108b557d8 llvm::report_fatal_error(llvm::Twine const&, bool) + 252
 8 swift-frontend 0x0000000108b556dc llvm::report_fatal_error(llvm::Twine const&, bool) + 0
 9 swift-frontend 0x0000000108affe00 void llvm::VerifierSupport::CheckFailed<llvm::Instruction*, llvm::MDNode const*>(llvm::Twine const&, llvm::Instruction* const&, llvm::MDNode const* const&) + 0
 10 swift-frontend 0x0000000108aa47d8 llvm::FPPassManager::runOnFunction(llvm::Function&) + 1136
 11 swift-frontend 0x0000000108aa3d90 llvm::legacy::FunctionPassManagerImpl::run(llvm::Function&) + 96
 12 swift-frontend 0x0000000108aaa408 llvm::legacy::FunctionPassManager::run(llvm::Function&) + 336
 13 swift-frontend 0x0000000104e3edb0 swift::performLLVMOptimizations(swift::IRGenOptions const&, llvm::Module*, llvm::TargetMachine*) + 1484
 14 swift-frontend 0x0000000104e3fcc8 swift::performLLVM(swift::IRGenOptions const&, swift::DiagnosticEngine&, llvm::sys::SmartMutex<false>*, llvm::GlobalVariable*, llvm::Module*, llvm::TargetMachine*, llvm::StringRef, swift::UnifiedStatsReporter*) + 2460
 15 swift-frontend 0x0000000104b36080 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 3084
 16 swift-frontend 0x0000000104b280c8 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 5548
 17 swift-frontend 0x0000000104abd100 main + 1136
 18 libdyld.dylib 0x0000000184ecc420 start + 4
 error: Abort trap: 6 (in target 'XXXX' from project 'XXXX')
 

I could actually trim it down, it is due to irresponsible and aggressive re-mapping of identifiers:

extension SomeStruct {
  func generateFileWrappers() throws -> [ String : FileWrapper ] {
    var wrappers = [ String : FileWrapper ]()
    
    for fragment in self.values {
      let wrapper = try self.wrapper(for      : fragment.attributedString,
                                     filename : fragment.name.appending(".rtf"))
      
      #if true // this crashes compiler:
        guard let wrapper = wrapper, let fn = wrapper.filename else { continue }
        // wrappers[fn] = wrapper
      #else // works
        wrappers[wrapper!.filename!] = wrapper
      #endif
    }
    return wrappers
  }

Note that the `self` has a `wrapper` function, and then there is the `wrapper` variable, and then I attempt to use it in a guard let context. The `guard` breaks it (i.e. if I use an `if let` it works).

@typesanitizer
Copy link

@swift-ci create

@aschwaighofer
Copy link
Member

Hi Helge,

Could you try with a snapshot build from https://swift.org/download/#snapshots ?

See https://swift.org/download/#using-downloads for how-to use a snapshot build.

We might get more information in the backtrace of the crash.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

3 participants