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-5974] compiler segfault #48533

Closed
swift-ci opened this issue Sep 24, 2017 · 7 comments
Closed

[SR-5974] compiler segfault #48533

swift-ci opened this issue Sep 24, 2017 · 7 comments

Comments

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Sep 24, 2017

Previous ID SR-5974
Radar rdar://problem/36256335
Original Reporter hexdreamer (JIRA User)
Type Bug
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, SILGen
Assignee @slavapestov
Priority Medium

md5: 9ee2e949e713f92c98ef4aa6d6eda8db

is duplicated by:

  • SR-6662 Compiler crash: Basic blocks must end with a terminator in throwing init

Issue Description:

CompileSwift normal x86_64 /Users/kenny/Projects/HiDef/HiDef/PDFileAudioSource.swift
    cd /Users/kenny/Projects/HiDef
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/kenny/Projects/HiDef/HiDef/PDAudioSource.swift /Users/kenny/Projects/HiDef/HiDef/PDAudioPlayer.swift /Users/kenny/Projects/HiDef/HiDef/ViewController.swift /Users/kenny/Projects/HiDef/HiDef/AppDelegate.swift /Users/kenny/Projects/HiDef/HiDef/PDAudioBuffer.swift -primary-file /Users/kenny/Projects/HiDef/HiDef/PDFileAudioSource.swift -target x86_64-apple-ios11.0 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk -I /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Products/Debug-iphonesimulator -F /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Products/Debug-iphonesimulator -enable-testing -g -module-cache-path /Users/kenny/build/ModuleCache -swift-version 4 -enforce-exclusivity=checked -D DEBUG -serialize-debugging-options -Xcc -I/Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/HiDef-generated-files.hmap -Xcc -I/Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/HiDef-own-target-headers.hmap -Xcc -I/Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/HiDef-all-target-headers.hmap -Xcc -iquote -Xcc /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/HiDef-project-headers.hmap -Xcc -I/Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/DerivedSources/x86_64 -Xcc -I/Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/kenny/Projects/HiDef -emit-module-doc-path /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/Objects-normal/x86_64/PDFileAudioSource~partial.swiftdoc -serialize-diagnostics-path /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/Objects-normal/x86_64/PDFileAudioSource.dia -Onone -module-name HiDef -emit-module-path /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/Objects-normal/x86_64/PDFileAudioSource~partial.swiftmodule -emit-dependencies-path /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/Objects-normal/x86_64/PDFileAudioSource.d -emit-reference-dependencies-path /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/Objects-normal/x86_64/PDFileAudioSource.swiftdeps -o /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/Objects-normal/x86_64/PDFileAudioSource.o -index-store-path /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Index/DataStore -index-system-modules

0  swift                    0x0000000105628dba PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x00000001056281f6 SignalHandler(int) + 662
2  libsystem_platform.dylib 0x00007fffe10eeb3a _sigtramp + 26
3  libsystem_platform.dylib 0x00007fb92c24ada0 _sigtramp + 1259717248
4  swift                    0x0000000101fdb60b llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>::CreateCondBr(llvm::Value*, llvm::BasicBlock*, llvm::BasicBlock*, llvm::MDNode*, llvm::MDNode*) + 75
5  swift                    0x00000001021509ed swift::SILVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::ValueBase*) + 108445
6  swift                    0x0000000102133a80 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 9152
7  swift                    0x000000010203e4be swift::irgen::IRGenerator::emitGlobalTopLevel() + 1022
8  swift                    0x0000000102115c4b performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**, unsigned int) + 1243
9  swift                    0x0000000101f9c17a performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 16778
10 swift                    0x0000000101f96784 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7716
11 swift                    0x0000000101f4b6a8 main + 12248
12 libdyld.dylib            0x00007fffe0edf235 start + 1
13 libdyld.dylib            0x0000000000000047 start + 521276947
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/kenny/Projects/HiDef/HiDef/PDAudioSource.swift /Users/kenny/Projects/HiDef/HiDef/PDAudioPlayer.swift /Users/kenny/Projects/HiDef/HiDef/ViewController.swift /Users/kenny/Projects/HiDef/HiDef/AppDelegate.swift /Users/kenny/Projects/HiDef/HiDef/PDAudioBuffer.swift -primary-file /Users/kenny/Projects/HiDef/HiDef/PDFileAudioSource.swift -target x86_64-apple-ios11.0 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk -I /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Products/Debug-iphonesimulator -F /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Products/Debug-iphonesimulator -enable-testing -g -module-cache-path /Users/kenny/build/ModuleCache -swift-version 4 -enforce-exclusivity=checked -D DEBUG -serialize-debugging-options -Xcc -I/Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/HiDef-generated-files.hmap -Xcc -I/Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/HiDef-own-target-headers.hmap -Xcc -I/Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/HiDef-all-target-headers.hmap -Xcc -iquote -Xcc /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/HiDef-project-headers.hmap -Xcc -I/Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/DerivedSources/x86_64 -Xcc -I/Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/kenny/Projects/HiDef -emit-module-doc-path /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/Objects-normal/x86_64/PDFileAudioSource~partial.swiftdoc -serialize-diagnostics-path /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/Objects-normal/x86_64/PDFileAudioSource.dia -Onone -module-name HiDef -emit-module-path /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/Objects-normal/x86_64/PDFileAudioSource~partial.swiftmodule -emit-dependencies-path /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/Objects-normal/x86_64/PDFileAudioSource.d -emit-reference-dependencies-path /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/Objects-normal/x86_64/PDFileAudioSource.swiftdeps -o /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Build/Intermediates.noindex/HiDef.build/Debug-iphonesimulator/HiDef.build/Objects-normal/x86_64/PDFileAudioSource.o -index-store-path /Users/kenny/build/HiDef-cnxbgeogfnawnegnhodnpwkhwnac/Index/DataStore -index-system-modules
1.  While emitting IR SIL function "@_T05HiDef17PDFileAudioSourceCACSg10Foundation3URLV3url_tcfc".
for 'init(url:)' at /Users/kenny/Projects/HiDef/HiDef/PDFileAudioSource.swift:16:5
@swift-ci
Copy link
Collaborator Author

@swift-ci swift-ci commented Sep 24, 2017

Comment by Kenny Leung (JIRA)

The code can be found at:

hexdreamer/hidef@cbb26d1

@belkadan
Copy link
Contributor

@belkadan belkadan commented Sep 25, 2017

@belkadan
Copy link
Contributor

@belkadan belkadan commented Sep 25, 2017

   SIL verification failed: Basic blocks must end with a terminator instruction: isa<TermInst>(BB.back())
In function:
// PDFileAudioSource.init(url:)
sil @_T05HiDef17PDFileAudioSourceCACSg10Foundation3URLV3url_tcfc : $@convention(method) (@owned URL, @owned PDFileAudioSource) -> @owned Optional<PDFileAudioSource> {

bb8:                                              // Preds: bb5
  %98 = unchecked_enum_data %86 : $Optional<PDAudioSource>, #Optional.some!enumelt.1 // user: %99
  %99 = unchecked_ref_cast %98 : $PDAudioSource to $PDFileAudioSource // user: %100
  store %99 to [init] %4 : $*PDFileAudioSource    // id: %100
  %101 = load [copy] %4 : $*PDFileAudioSource     // user: %102
  %102 = enum $Optional<PDFileAudioSource>, #Optional.some!enumelt.1, %101 : $PDFileAudioSource // user: %93

The relevant initializer:

    init?(url:URL) {
        var audioFileID :AudioFileID?
        let status = AudioFileOpenURL(url as CFURL, .readPermission, 0, &audioFileID)
        if ( status != 0 ) {
            return nil
        }
        guard let nnAudioFileID = audioFileID else {
            return nil
        }
        
        self.fileURL = url
        self.mAudioFile = nnAudioFileID
    }

…with a base class in another file:

class PDAudioSource {

    let mDataFormat:AudioStreamBasicDescription                     // 2

    init?() {
        return nil
    }
    
    func fillBuffer(_ buffer:PDAudioBuffer) {}
}

That means there's an implicitly inserted super.init(), which we then have to check for failure. (It will always fail, but that's not important at the moment; this is failing in a non-WMO build where we can't see that.) Sounds like @slavapestov's area.

@belkadan
Copy link
Contributor

@belkadan belkadan commented Jan 2, 2018

Reduced test case in SR-6662.

@swift-ci create

@slavapestov
Copy link
Member

@slavapestov slavapestov commented Jan 8, 2018

@AnnaZaks
Copy link
Mannequin

@AnnaZaks AnnaZaks mannequin commented Jul 26, 2018

hexdreamer (JIRA User), Could you verify if the problem is fixed and if so move the JIRA to "Closed"?

Thanks!
Anna

@swift-ci
Copy link
Collaborator Author

@swift-ci swift-ci commented Jul 27, 2018

Comment by Kenny Leung (JIRA)

Confirmed that this is fixed in the Swift Development Snapshot from 5/13/18.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants