swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.57k stars 10.36k forks source link

[SR-6023] Fatal error encountered while reading from module #48580

Open iby opened 7 years ago

iby commented 7 years ago
Previous ID SR-6023
Radar None
Original Reporter @iby
Type Bug

Attachment: Download

Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, CompilerCrash | |Assignee | None | |Priority | Medium | md5: a1a151f4b5e245a9f1117780ba73dea0

Issue Description:

Some nasty compiler errors while playing around with static library.

<unknown>:0: error: fatal error encountered while reading from module 'SwiftyFFmpeg'; please file a bug report with your project and the crash log

*** DESERIALIZATION FAILURE (please include this section in any bug report) ***
top-level value not found
Cross-reference to module '__ObjC'
... AVCodecContext

0  swift                    0x0000000112f6edba PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x0000000112f6e1f6 SignalHandler(int) + 662
2  libsystem_platform.dylib 0x00007fffdc0f5b3a _sigtramp + 26
3  libsystem_platform.dylib 0x0000000000000004 _sigtramp + 602973412
4  libsystem_c.dylib        0x00007fffdbf7a420 abort + 129
5  swift                    0x000000011066ac51 swift::ModuleFile::fatal(llvm::Error) + 1569
6  swift                    0x000000011067f110 swift::ModuleFile::resolveCrossReference(swift::ModuleDecl*, unsigned int) + 10688
7  swift                    0x000000011066eb05 swift::ModuleFile::getDeclChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 14837
8  swift                    0x0000000110672d9a swift::ModuleFile::getDeclChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 31882
9  swift                    0x0000000110683ca1 swift::ModuleFile::loadAllMembers(swift::Decl*, unsigned long long) + 657
10 swift                    0x0000000110add536 swift::IterableDeclContext::loadAllMembers() const + 134
11 swift                    0x0000000110aaee89 (anonymous namespace)::Traversal::visitNominalTypeDecl(swift::NominalTypeDecl*) + 425
12 swift                    0x0000000110aac9ee (anonymous namespace)::Traversal::doIt(swift::Decl*) + 382
13 swift                    0x00000001103356cf swift::SILPassManager::SILPassManager(swift::SILModule*, llvm::StringRef) + 1807
14 swift                    0x000000011033bd0f swift::runSILDiagnosticPasses(swift::SILModule&) + 175
15 swift                    0x000000010f8e1604 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 13844
16 swift                    0x000000010f8dc784 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7716
17 swift                    0x000000010f8916a8 main + 12248
18 libdyld.dylib            0x00007fffdbee6235 start + 1
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -emit-module /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/Objects-normal/x86_64/Error~partial.swiftmodule /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/Objects-normal/x86_64/Extension~partial.swiftmodule /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/Objects-normal/x86_64/Frame~partial.swiftmodule /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/Objects-normal/x86_64/Loggable~partial.swiftmodule /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/Objects-normal/x86_64/Packet~partial.swiftmodule /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/Objects-normal/x86_64/Codec.Context~partial.swiftmodule /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/Objects-normal/x86_64/Codec.Context.Encoder~partial.swiftmodule /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/Objects-normal/x86_64/Codec.Context.Decoder~partial.swiftmodule /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/Objects-normal/x86_64/Format.Context.Input~partial.swiftmodule /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/Objects-normal/x86_64/Format.Context.Output~partial.swiftmodule /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/Objects-normal/x86_64/Format.Stream~partial.swiftmodule /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/Objects-normal/x86_64/Format.Context~partial.swiftmodule -parse-as-library -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -I /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Products/Debug -F /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Products/Debug -F /Users/ianbytchek/Development/gifox/dependency/Carthage/Build/Mac -F /Users/ianbytchek/Development/gifox/dependency/Carthage/Checkouts/mac-framework -F /Users/ianbytchek/Development/gifox/library/DevMate -enable-testing -g -module-cache-path /Users/ianbytchek/Library/Developer/Xcode/DerivedData/ModuleCache -swift-version 4 -enforce-exclusivity=checked -D DEBUG -D DEBUG_SCHEME -serialize-debugging-options -Xcc -I/Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/SwiftyFFmpeg - Static-generated-files.hmap -Xcc -I/Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/SwiftyFFmpeg - Static-own-target-headers.hmap -Xcc -I/Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/SwiftyFFmpeg - Static-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/SwiftyFFmpeg - Static-project-headers.hmap -Xcc -I/Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Products/Debug/include -Xcc -Ilibrary/FFmpeg/Header -Xcc -Ilibrary/FFmpeg/Header/libavcodec -Xcc -Ilibrary/FFmpeg/Header/libavfilter -Xcc -Ilibrary/FFmpeg/Header/libavformat -Xcc -Ilibrary/FFmpeg/Header/libavutil -Xcc -Ilibrary/FFmpeg/Header/libswscale -Xcc -I/Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/DerivedSources/x86_64 -Xcc -I/Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/DerivedSources -Xcc -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0 -Xcc -DDEBUG_SCHEME=1 -Xcc -DDEBUG_LICENSING=0 -Xcc -DSTATIC_LIBRARY=1 -Xcc -working-directory/Users/ianbytchek/Development/gifox -emit-module-doc-path /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/Objects-normal/x86_64/SwiftyFFmpeg.swiftdoc -import-objc-header /Users/ianbytchek/Development/gifox/source/SwiftyFFmpeg/Bridge.h -module-name SwiftyFFmpeg -emit-objc-header-path /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/Objects-normal/x86_64/SwiftyFFmpeg-Swift.h -o /Users/ianbytchek/Library/Developer/Xcode/DerivedData/Gifox-cdcytgodcmaptpcooikadytctejm/Build/Intermediates.noindex/Gifox.build/Debug/SwiftyFFmpeg - Static.build/Objects-normal/x86_64/SwiftyFFmpeg.swiftmodule
1.  While loading members for 'EncoderContext' in module 'SwiftyFFmpeg'
2.  While deserializing decl #&#8203;11 (CONSTRUCTOR_DECL) in 'SwiftyFFmpeg'
3.  While deserializing decl #&#8203;19 (XREF) in 'SwiftyFFmpeg'
4.  Cross-reference to module 'SwiftyFFmpeg'
... CodecContext
... init
belkadan commented 7 years ago

Can you attach the project?

iby commented 7 years ago

See attached project and gif. I traced it down to presence of a module map in the same folder with compiled code – they somehow get included in the equation and mess things up:

It appears the compiler "goes extra step" and includes module maps in folders with code, even when not asked to?

P. S. You can go further and remove framework target, it still fails if module map resides in `Foo` folder.

![](2017-09-29 14.56.56.gif)

iby commented 7 years ago

I'm coming across the same bug in a different situation with static library being used from a framework.