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-10571] 'Deserialization Failure' crash when marking struct initializers referencing C unions as @inlinable #52971

Closed
swift-ci opened this issue Apr 28, 2019 · 3 comments
Assignees
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 good first issue Good for newcomers

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-10571
Radar rdar://problem/50337188
Original Reporter luiz (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

Xcode 10.2.1 (10E1001)
macOS 10.14.4 (18E226)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, ClangImporter, CompilerCrash, StarterBug
Assignee @typesanitizer
Priority Medium

md5: b3d6c73bb2606c4a77383190d089a3d7

Issue Description:

The following small reproduction project currently crashes in Xcode 10.2.1:

1. Clone https://github.com/LuizZak/swift-crash-repro-case
2. Run `swift test`

Expected result:

Have the program compile and test successfully

Actual result:

Test program crashes while compiling:

<unknown>:0: error: fatal error encountered while reading from module 'CrashRepro'; 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)
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/luizfernandosilva/Desktop/CrashRepro/Tests/CrashReproTests/RgbaTests.swift /Users/luizfernandosilva/Desktop/CrashRepro/Tests/CrashReproTests/XCTestManifests.swift -emit-module-path /Users/luizfernandosilva/Desktop/CrashRepro/.build/x86_64-apple-macosx/debug/CrashReproTests.build/RgbaTests~partial.swiftmodule -emit-module-doc-path /Users/luizfernandosilva/Desktop/CrashRepro/.build/x86_64-apple-macosx/debug/CrashReproTests.build/RgbaTests~partial.swiftdoc -emit-dependencies-path /Users/luizfernandosilva/Desktop/CrashRepro/.build/x86_64-apple-macosx/debug/CrashReproTests.build/RgbaTests.d -emit-reference-dependencies-path /Users/luizfernandosilva/Desktop/CrashRepro/.build/x86_64-apple-macosx/debug/CrashReproTests.build/RgbaTests.swiftdeps -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I /Users/luizfernandosilva/Desktop/CrashRepro/.build/x86_64-apple-macosx/debug -I /Users/luizfernandosilva/Desktop/CrashRepro/Sources/CSource/include -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /Users/luizfernandosilva/Desktop/CrashRepro/.build/x86_64-apple-macosx/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -color-diagnostics -enable-anonymous-context-mangled-names -Xcc -fmodule-map-file=/Users/luizfernandosilva/Desktop/CrashRepro/.build/x86_64-apple-macosx/debug/CSource.build/module.modulemap -parse-as-library -module-name CrashReproTests -o /Users/luizfernandosilva/Desktop/CrashRepro/.build/x86_64-apple-macosx/debug/CrashReproTests.build/RgbaTests.swift.o -index-store-path /Users/luizfernandosilva/Desktop/CrashRepro/.build/x86_64-apple-macosx/debug/index/store -index-system-modules 
1.  While running pass #&#8203;235 SILModuleTransform "MandatorySILLinker".
2.  While deserializing SIL function "$__Unnamed_struct___Anonymous_field1$r$getter"
0  swift                    0x0000000109ed4ee3 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x0000000109ed46bc SignalHandler(int) + 348
2  libsystem_platform.dylib 0x00007fff5e6f4b5d _sigtramp + 29
3  libsystem_platform.dylib 000000000000000000 _sigtramp + 2710615232
4  libsystem_c.dylib        0x00007fff5e5b46a6 abort + 127
5  swift                    0x00000001070541e0 swift::ModuleFile::fatal(llvm::Error) + 1856
6  swift                    0x000000010707a560 swift::SILDeserializer::readSILFunctionChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, swift::SILFunction*, llvm::StringRef, bool, bool) + 9328
7  swift                    0x000000010708b8e1 swift::SILDeserializer::lookupSILFunction(swift::SILFunction*) + 673
8  swift                    0x0000000106d4275b swift::SILLinkerVisitor::maybeAddFunctionToWorklist(swift::SILFunction*) + 299
9  swift                    0x0000000106d42984 swift::SILLinkerVisitor::processFunction(swift::SILFunction*) + 292
10 swift                    0x0000000106c21fe7 (anonymous namespace)::SILLinker::run() + 263
11 swift                    0x0000000106b2c3e8 swift::SILPassManager::execute() + 7416
12 swift                    0x0000000106b3065b swift::runSILDiagnosticPasses(swift::SILModule&) + 2347
13 swift                    0x0000000105d3617e performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 36734
14 swift                    0x0000000105d2992e swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6862
05cc79ce main + 1246
16 libdyld.dylib            0x00007fff5e50f3d5 start + 1
<unknown>:0: error: unable to execute command: Abort trap: 6
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)
@belkadan
Copy link
Contributor

belkadan commented May 3, 2019

Ooops. We're mangling all getters and setters for anonymous struct fields the same way: $__Unnamed_struct___Anonymous_field1$r$getter. We should be including the hierarchy like the type has: Rgba64.__Unnamed_union___Anonymous_field0.__Unnamed_struct___Anonymous_field1.

@belkadan
Copy link
Contributor

belkadan commented May 3, 2019

The simplest fix for this is probably to change getAccessorDeclarationName to use a mangled name for the containing StructDecl, using ASTMangler::mangleDeclAsUSR (and no prefix). Tagging as a starter bug for someone to try that.

@typesanitizer
Copy link

Fix merged in GitHub PR 26175:

#26175

@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
This issue was closed.
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 good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants