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-7887] Source files with same name cause crash in SIL deserializer #50422

Open
swift-ci opened this issue Jun 5, 2018 · 7 comments
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jun 5, 2018

Previous ID SR-7887
Radar rdar://problem/40853563
Original Reporter fpillet (JIRA User)
Type Bug

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
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee dingobye (JIRA)
Priority Medium

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:

  1. 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/LocalizedStringspartial.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.swiftmodule

  2. While 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:

@harlanhaskins
Copy link
Collaborator

Thanks for filing this! I'm able to reproduce the crash on my machine.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Jun 6, 2018

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.

@belkadan
Copy link
Contributor

belkadan commented Jun 6, 2018

@DougGregor said he was looking at another case of this.

@swift-ci create

@swift-ci
Copy link
Collaborator Author

swift-ci commented Jun 7, 2018

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:

#17033

@belkadan
Copy link
Contributor

belkadan commented Jun 7, 2018

cc also @aciidb0mb3r

@huonw
Copy link
Mannequin

huonw mannequin commented Jun 12, 2018

I believe this occurs with the new build system, but not the old one.

@belkadan
Copy link
Contributor

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.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 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 crash Bug: A crash, i.e., an abnormal termination of software
Projects
None yet
Development

No branches or pull requests

4 participants