Closed dmcyk closed 5 years ago
cc @jckarter
Can you share any more detail about how you built the two modules? I tried this, and couldn't reproduce the crash:
$ cat a.swift
public protocol Foo {}
public struct FooImpl: Foo {
public init() {}
}
public func anyFoo() -> __opaque Foo {
return FooImpl()
}
$ cat b.swift
import modulea
dump(anyFoo())
$ ./bin/swiftc -force-single-frontend-invocation -emit-module-path modulea.swiftmodule -c -module-name modulea a.swift
$ ./bin/swiftc -c -I . b.swift
ah sorry, should have written what the included `fuzz.zip` was.
I used SwiftPM (`swift run`), in the archive you can find ready package.
I tried compiling it now the way you did it and I'm getting same assertion.
I was testing with the toolchain you provided few days ago though, is it possible you were testing including the latest commits?
$ cat ../Info.plist
...
<key>Aliases</key>
<array>
<string>PR21137</string>
</array>
<key>CFBundleIdentifier</key>
<string>org.swift.pr.21137.170</string>
...
<key>ShortDisplayName</key>
<string>Swift PR - 21137 (170)</string>
</dict>
</plist>
$ cat a.swift
public protocol Foo {}
public struct FooImpl: Foo {
public init() {}
}
public func anyFoo() -> __opaque Foo {
return FooImpl()
}
$ cat b.swift
import modulea
dump(anyFoo())
$ ./bin/swiftc -force-single-frontend-invocation -emit-module-path modulea.swiftmodule -c -module-name modulea a.swift
$ ./bin/swiftc -c -I . b.swift
Assertion failed: (hasInterfaceType() && "No interface type was set"), function getInterfaceType, file /Users/buildnode/jenkins/workspace/swift-PR-toolchain-osx/branch-master/swift/lib/AST/Decl.cpp, line 2422.
Stack dump:
0. Program arguments: /Users/damian/Downloads/Library/Developer/Toolchains/swift-PR-21137-170.xctoolchain/usr/bin/swift -frontend -c -primary-file b.swift -target x86_64-apple-darwin18.2.0 -enable-objc-interop -I . -color-diagnostics -module-name b -o b.o
0 swift 0x000000010fed4218 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1 swift 0x000000010fed3495 llvm::sys::RunSignalHandlers() + 85
2 swift 0x000000010fed4822 SignalHandler(int) + 258
3 libsystem_platform.dylib 0x00007fff5fc47b3d _sigtramp + 29
4 libsystem_platform.dylib 0x000000011a384938 _sigtramp + 3128151576
5 libsystem_c.dylib 0x00007fff5fb051c9 abort + 127
6 libsystem_c.dylib 0x00007fff5facd868 basename_r + 0
7 swift 0x000000010d5ce132 swift::ValueDecl::getInterfaceType() const + 50
8 swift 0x000000010d5a3c35 (anonymous namespace)::Verifier::verifyChecked(swift::ValueDecl*) + 21
9 swift 0x000000010d59b646 (anonymous namespace)::Verifier::walkToDeclPost(swift::Decl*) + 326
10 swift 0x000000010d5a5c1c (anonymous namespace)::Traversal::doIt(swift::Decl*) + 252
11 swift 0x000000010d5a5b0b swift::Decl::walk(swift::ASTWalker&) + 27
12 swift 0x000000010d592365 swift::verify(swift::Decl*) + 133
13 swift 0x000000010d1f6a5b swift::ModuleFile::verify() const + 91
14 swift 0x000000010d257ba8 swift::SerializedModuleLoaderBase::verifyAllModules() + 40
15 swift 0x000000010d524fd9 swift::ASTContext::verifyAllLoadedModules() const + 89
16 swift 0x000000010d1abb08 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 1432
17 swift 0x000000010c974206 swift::CompilerInstance::parseAndTypeCheckMainFileUpTo(swift::SourceFile::ASTStage_t, swift::PersistentParserState&, swift::DelayedParsingCallbacks*, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>) + 502
18 swift 0x000000010c972b73 swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t) + 435
19 swift 0x000000010c972278 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 616
20 swift 0x000000010c14e168 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1704
21 swift 0x000000010c14ca52 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2978
22 swift 0x000000010c0fea7e main + 686
23 libdyld.dylib 0x00007fff5fa5ced9 start + 1
24 libdyld.dylib 0x000000000000000f start + 2690265399
fish: './bin/swiftc -c -I . b.swift' terminated by signal SIGABRT (Abort)
I'll ask swift-ci to build a new toolchain to see whether I incidentally fixed this.
hm, that's confusing.
I've tried latest build and I'm getting same assertion.
I'm on latest commit though.
$ ./bin/swiftc -v
Apple Swift version 5.0-dev (LLVM f63b283c71, Clang 41ac4c4262, Swift 551d614228)
Target: x86_64-apple-darwin18.2.0
OK, thanks for giving it another try. Maybe I can try something to speculatively fix the issue.
Maybe this will address the crash: https://github.com/apple/swift/pull/21137/commits/68cc0b5a2809f9678e05b0001d01f1cb39b50f7c I started another toolchain build for you to try out.
Still the same assertion fails. Could this be something with my environment that you can't reproduce the issue locally? I will try later too on another machine.
@jckarter I've tried it again with latest toolchain from the PR and seems like that's fixed
Great, thanks for following up!
Attachment: Download
Environment
Swift toolchain **swift-PR-21137-170**, from https://github.com/apple/swift/pull/21137Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug | |Assignee | @jckarter | |Priority | Medium | md5: 7aa753d19e307b4d28134845dd2ca3cdIssue Description:
Trying to use public function from module A, from module B causes the compiler to crash with an assertion.
Module A:
Module B:
Stack dump: