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-7887] Source files with same name cause crash in SIL deserializer #50422
Comments
Thanks for filing this! I'm able to reproduce the crash on my machine. |
Comment by Florent Pillet (JIRA) FWIW, this is happening on a MBP with a single APFS volume. I'm also getting it when compiling on Linux, but only in Debug mode so far. |
@DougGregor said he was looking at another case of this. @swift-ci create |
Comment by Ding Ye (JIRA) This is caused by filesystems that are case-insensitive, as @DougGregor mentioned. The two intermediate output modulefiles (i.e.., localizedStrings~partial.swiftmodule and LocalizedStrings~partial.swiftmodule) are emitted under the same path (e.g. SILCrasher/.build/x86_64-apple-macosx10.10/debug/SILCrasher.build/), resulting in writing to the same file in a case-insensitive filesystem. The contents of the previous output is overridden by the latter one, which causes the crash afterwards. I tested it on two partitions: -— Mac OS Extended (Journaled): CRASH -— Mac OS Extended (Case-sentive, journaled): COMPILE In fact, Driver does checking for duplicate base filenames of inputs. However, it is performed in a case-sensitive manner. The PR below makes such checking case-insensitive: |
cc also @aciidb0mb3r |
I believe this occurs with the new build system, but not the old one. |
Update: SwiftPM's fixed the issue where it accidentally used the same name for two outputs, and that covers all the practical cases of this. The compiler crash is basically "if you feed the same partial module into merge-modules and leave out one of the partial modules, the compiler crashes", which…well, the compiler should never crash, but that's so far from a practical issue. |
Attachment: Download
Environment
MacOS 10.13.5
Xcode 9.4 / Xcode 10.0 beta
Swift 4.1.2 / Swift .4.2
Additional Detail from JIRA
md5: 6974f80ac7052c55fa15079c4eb1f63c
Issue Description:
A simple project with a couple files carrying the same names (albeit using different case) at different level in the source hierarchy can crash the SIL deserializer.
This happens on Swift 4.1 and Swift 4.2.
Attached is a test case project reduced to the bare minimum to cause SIL to crash.
Typical crash log (here with Xcode 10 beta / Swift 4.2 tools):
Compile Swift Module 'SILCrasher' (2 sources)
:0: error: fatal error encountered while reading from module 'SILCrasher'; please file a bug report with your project and the crash log
*** DESERIALIZATION FAILURE (please include this section in any bug report) ***
(see "While..." info below)
0 swift 0x000000010c216c5a PrintStackTraceSignalHandler(void*) + 42
1 swift 0x000000010c216066 SignalHandler(int) + 966
2 libsystem_platform.dylib 0x00007fff75d78f5a _sigtramp + 26
3 libsystem_platform.dylib 0x00007fb0a9b80600 _sigtramp + 870348480
4 libsystem_c.dylib 0x00007fff75b161ae abort + 127
5 swift 0x00000001096bc99b swift::ModuleFile::fatal(llvm::Error) + 1915
6 swift 0x00000001096e0b2e swift::SILDeserializer::readSILFunction(llvm::PointerEmbeddedInt<unsigned int, 31>, swift::SILFunction*, llvm::StringRef, bool, bool) + 7678
7 swift 0x00000001096f63bd swift::SILDeserializer::getAllSILFunctions() + 893
8 swift 0x000000010979ef5a swift::SerializedSILLoader::getAllForModule(swift::Identifier, swift::FileUnit*) + 170
9 swift 0x00000001084f1dbe performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 34750
10 swift 0x00000001084e610f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7839
11 swift 0x000000010848fc48 main + 13144
12 libdyld.dylib 0x00007fff75a6a015 start + 1
Stack dump:
Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -merge-modules -emit-module /Users/fpillet/Work/compiler/.build/x86_64-apple-macosx10.10/debug/SILCrasher.build/LocalizedStrings
partial.swiftmodule /Users/fpillet/Work/compiler/.build/x86_64-apple-macosx10.10/debug/SILCrasher.build/localizedStringspartial.swiftmodule -parse-as-library -sil-merge-partial-modules -disable-diagnostic-passes -disable-sil-perf-optzns -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I /Users/fpillet/Work/compiler/.build/x86_64-apple-macosx10.10/debug -F /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /Users/fpillet/Work/compiler/.build/x86_64-apple-macosx10.10/debug/ModuleCache -swift-version 4 -Onone -D SWIFT_PACKAGE -D DEBUG -color-diagnostics -emit-module-doc-path /Users/fpillet/Work/compiler/.build/x86_64-apple-macosx10.10/debug/SILCrasher.swiftdoc -module-name SILCrasher -o /Users/fpillet/Work/compiler/.build/x86_64-apple-macosx10.10/debug/SILCrasher.swiftmoduleWhile deserializing SIL function "$S10SILCrasher16LocalizedStringsC6string3for4langSSSi_SStF"
:0: error: unable to execute command: Abort trap: 6
:0: error: merge-module command failed due to signal 6 (use -v to see invocation)
error: terminated(1): /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/fpillet/Work/compiler/.build/debug.yaml main output:
The text was updated successfully, but these errors were encountered: