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-13797] Segfault in swift::PartialApplyInst::create #56194

Open
swift-ci opened this issue Oct 30, 2020 · 3 comments
Open

[SR-13797] Segfault in swift::PartialApplyInst::create #56194

swift-ci opened this issue Oct 30, 2020 · 3 comments

Comments

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Oct 30, 2020

Previous ID SR-13797
Radar rdar://problem/70892081
Original Reporter hughbe (JIRA User)
Type Bug
Environment

macOS Catalina 10.15.7 (19H2)

Xcode Version 12.0.1 (12A7300)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, StarterBug, TypeChecker
Assignee None
Priority Medium

md5: 2ec8b445c93ac5fadb92557f27dbf8d7

Issue Description:

Steps to reproduce:

Expected:

Although the file is obviously disgustingly long, it should not crash the compiler

Actual:**

Segmentation fault: 11

CompileSwift normal x86_64 /Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/FullDumpTests.swift (in target 'PstReaderTests' from project 'PstReader')
    cd /Users/hugh/Documents/GitHub/PstReader
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/AutoGeneratedTests.swift /Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/DumpPstFileTests.swift -primary-file /Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/FullDumpTests.swift /Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/Helpers.swift /Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/PerformanceTests.swift /Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/PstFileTests.swift /Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/URL+ForResource.swift /Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/XCTestManifests.swift -emit-module-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/FullDumpTests\~partial.swiftmodule -emit-module-doc-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/FullDumpTests\~partial.swiftdoc -emit-module-source-info-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/FullDumpTests\~partial.swiftsourceinfo -serialize-diagnostics-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/FullDumpTests.dia -emit-dependencies-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/FullDumpTests.d -emit-reference-dependencies-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/FullDumpTests.swiftdeps -target x86_64-apple-macos10.15 -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -I /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Products/Debug -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Products/Debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /Users/hugh/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 5 -enforce-exclusivity\=checked -Onone -D SWIFT_PACKAGE -D DEBUG -D Xcode -serialize-debugging-options -serialize-debugging-options -Xcc -working-directory -Xcc /Users/hugh/Documents/GitHub/PstReader -enable-anonymous-context-mangled-names -Xcc -I/Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Products/Debug/include -Xcc -I/Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/DerivedSources-normal/x86_64 -Xcc -I/Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/DerivedSources/x86_64 -Xcc -I/Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/DerivedSources -Xcc -DSWIFT_PACKAGE -Xcc -DDEBUG\=1 -target-sdk-version 10.15.6 -module-name PstReaderTests -o /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/FullDumpTests.o -index-store-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Index/DataStore -index-system-modules


/Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/FullDumpTests.swift:60706:173: warning: conditional downcast from 'FolderEntryID?' to 'FolderEntryID' does nothing
XCTAssertEqual(0x00000000, ((messageDetails.extendedRuleMessageActions!.ruleActionsBuffer.actionBlocks[0].actionData as? ActionBlock.MoveCopyActionDataExtended)!.folderEID as? FolderEntryID)!.flags)
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
                                                                                                                                                                           
/Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/FullDumpTests.swift:60707:219: warning: conditional downcast from 'FolderEntryID?' to 'FolderEntryID' does nothing
XCTAssertEqual(UUID(uuidString: "CBB89467-E606-4248-A820-9CC1E3B9A128"), ((messageDetails.extendedRuleMessageActions!.ruleActionsBuffer.actionBlocks[0].actionData as? ActionBlock.MoveCopyActionDataExtended)!.folderEID as? FolderEntryID)!.providerUid)
                                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
                                                                                                                                                                                                                         
/Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/FullDumpTests.swift:60708:177: warning: conditional downcast from 'FolderEntryID?' to 'FolderEntryID' does nothing
XCTAssertEqual(.privateFolder, ((messageDetails.extendedRuleMessageActions!.ruleActionsBuffer.actionBlocks[0].actionData as? ActionBlock.MoveCopyActionDataExtended)!.folderEID as? FolderEntryID)!.folderType)
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
                                                                                                                                                                               
/Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/FullDumpTests.swift:60709:219: warning: conditional downcast from 'FolderEntryID?' to 'FolderEntryID' does nothing
XCTAssertEqual(UUID(uuidString: "F711B14A-92C8-4094-9843-750BE6086BC4"), ((messageDetails.extendedRuleMessageActions!.ruleActionsBuffer.actionBlocks[0].actionData as? ActionBlock.MoveCopyActionDataExtended)!.folderEID as? FolderEntryID)!.databaseGuid)
                                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
                                                                                                                                                                                                                         
/Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/FullDumpTests.swift:60710:179: warning: conditional downcast from 'FolderEntryID?' to 'FolderEntryID' does nothing
XCTAssertEqual(8163873836236800, ((messageDetails.extendedRuleMessageActions!.ruleActionsBuffer.actionBlocks[0].actionData as? ActionBlock.MoveCopyActionDataExtended)!.folderEID as? FolderEntryID)!.globalCounter)
                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
                                                                                                                                                                                 
/Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/FullDumpTests.swift:60711:169: warning: conditional downcast from 'FolderEntryID?' to 'FolderEntryID' does nothing
XCTAssertEqual(0x0000, ((messageDetails.extendedRuleMessageActions!.ruleActionsBuffer.actionBlocks[0].actionData as? ActionBlock.MoveCopyActionDataExtended)!.folderEID as? FolderEntryID)!.pad)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
                                                                                                                                                                       
/Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/FullDumpTests.swift:62136:173: warning: conditional downcast from 'FolderEntryID?' to 'FolderEntryID' does nothing
XCTAssertEqual(0x00000000, ((messageDetails.extendedRuleMessageActions!.ruleActionsBuffer.actionBlocks[0].actionData as? ActionBlock.MoveCopyActionDataExtended)!.folderEID as? FolderEntryID)!.flags)
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
                                                                                                                                                                           
/Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/FullDumpTests.swift:62137:219: warning: conditional downcast from 'FolderEntryID?' to 'FolderEntryID' does nothing
XCTAssertEqual(UUID(uuidString: "CBB89467-E606-4248-A820-9CC1E3B9A128"), ((messageDetails.extendedRuleMessageActions!.ruleActionsBuffer.actionBlocks[0].actionData as? ActionBlock.MoveCopyActionDataExtended)!.folderEID as? FolderEntryID)!.providerUid)
                                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
                                                                                                                                                                                                                         
/Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/FullDumpTests.swift:62138:177: warning: conditional downcast from 'FolderEntryID?' to 'FolderEntryID' does nothing
XCTAssertEqual(.privateFolder, ((messageDetails.extendedRuleMessageActions!.ruleActionsBuffer.actionBlocks[0].actionData as? ActionBlock.MoveCopyActionDataExtended)!.folderEID as? FolderEntryID)!.folderType)
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
                                                                                                                                                                               
/Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/FullDumpTests.swift:62139:219: warning: conditional downcast from 'FolderEntryID?' to 'FolderEntryID' does nothing
XCTAssertEqual(UUID(uuidString: "F711B14A-92C8-4094-9843-750BE6086BC4"), ((messageDetails.extendedRuleMessageActions!.ruleActionsBuffer.actionBlocks[0].actionData as? ActionBlock.MoveCopyActionDataExtended)!.folderEID as? FolderEntryID)!.databaseGuid)
                                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
                                                                                                                                                                                                                         
/Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/FullDumpTests.swift:62140:180: warning: conditional downcast from 'FolderEntryID?' to 'FolderEntryID' does nothing
XCTAssertEqual(22519097648480256, ((messageDetails.extendedRuleMessageActions!.ruleActionsBuffer.actionBlocks[0].actionData as? ActionBlock.MoveCopyActionDataExtended)!.folderEID as? FolderEntryID)!.globalCounter)
                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
                                                                                                                                                                                  
/Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/FullDumpTests.swift:62141:169: warning: conditional downcast from 'FolderEntryID?' to 'FolderEntryID' does nothing
XCTAssertEqual(0x0000, ((messageDetails.extendedRuleMessageActions!.ruleActionsBuffer.actionBlocks[0].actionData as? ActionBlock.MoveCopyActionDataExtended)!.folderEID as? FolderEntryID)!.pad)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
                                                                                                                                                                       
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/AutoGeneratedTests.swift /Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/DumpPstFileTests.swift -primary-file /Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/FullDumpTests.swift -primary-file /Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/Helpers.swift /Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/PerformanceTests.swift /Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/PstFileTests.swift /Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/URL+ForResource.swift /Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/XCTestManifests.swift -emit-module-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/FullDumpTests~partial.swiftmodule -emit-module-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/Helpers~partial.swiftmodule -emit-module-doc-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/FullDumpTests~partial.swiftdoc -emit-module-doc-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/Helpers~partial.swiftdoc -emit-module-source-info-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/FullDumpTests~partial.swiftsourceinfo -emit-module-source-info-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/Helpers~partial.swiftsourceinfo -serialize-diagnostics-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/FullDumpTests.dia -serialize-diagnostics-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/Helpers.dia -emit-dependencies-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/FullDumpTests.d -emit-dependencies-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/Helpers.d -emit-reference-dependencies-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/FullDumpTests.swiftdeps -emit-reference-dependencies-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/Helpers.swiftdeps -target x86_64-apple-macos10.15 -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -I /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Products/Debug -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Products/Debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /Users/hugh/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 5 -enforce-exclusivity=checked -Onone -D SWIFT_PACKAGE -D DEBUG -D Xcode -serialize-debugging-options -serialize-debugging-options -Xcc -working-directory -Xcc /Users/hugh/Documents/GitHub/PstReader -enable-anonymous-context-mangled-names -Xcc -I/Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Products/Debug/include -Xcc -I/Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/DerivedSources-normal/x86_64 -Xcc -I/Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/DerivedSources/x86_64 -Xcc -I/Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/DerivedSources -Xcc -DSWIFT_PACKAGE -Xcc -DDEBUG=1 -target-sdk-version 10.15.6 -module-name PstReaderTests -o /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/FullDumpTests.o -o /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Build/Intermediates.noindex/PstReader.build/Debug/PstReaderTests.build/Objects-normal/x86_64/Helpers.o -index-store-path /Users/hugh/Library/Developer/Xcode/DerivedData/PstReader-dsrnpdhvjnpkcbapjyjjnqimamce/Index/DataStore -index-system-modules 
1.  Apple Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1)
2.  While evaluating request SILGenSourceFileRequest(SIL Generation for file "/Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/FullDumpTests.swift")
3.  While emitting SIL for 'testOst()' (at /Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/FullDumpTests.swift:14:5)
4.  While silgen emitFunction SIL function "@$s14PstReaderTests08FullDumpC0C7testOstyyKF".
 for 'testOst()' (at /Users/hugh/Documents/GitHub/PstReader/Tests/PstReaderTests/FullDumpTests.swift:14:5)
0  swift                    0x0000000112316865 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x0000000112315865 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x0000000112316e1f SignalHandler(int) + 111
3  libsystem_platform.dylib 0x00007fff6b1a35fd _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603338719283744
5  swift                    0x000000010ea20eeb swift::PartialApplyInst::create(swift::SILDebugLocation, swift::SILValue, llvm::ArrayRef<swift::SILValue>, swift::SubstitutionMap, swift::ParameterConvention, swift::SILFunction&, swift::SILOpenedArchetypesState&, swift::GenericSpecializationInformation const*, swift::PartialApplyInst::OnStackKind) + 347
6  swift                    0x000000010e3afcfc swift::Lowering::SILGenFunction::emitClosureValue(swift::SILLocation, swift::SILDeclRef, swift::CanType, swift::SubstitutionMap) + 2060
7  swift                    0x000000010e3a4213 (anonymous namespace)::RValueEmitter::visitAbstractClosureExpr(swift::AbstractClosureExpr*, swift::Lowering::SGFContext) + 435
8  swift                    0x000000010e38f359 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 121
9  swift                    0x000000010e2f0000 swift::Lowering::ArgumentSource::getAsSingleValue(swift::Lowering::SILGenFunction&, swift::Lowering::SGFContext) && + 928
10 swift                    0x000000010e366fcc swift::Lowering::SILGenFunction::emitConvertedRValue(swift::SILLocation, swift::Lowering::Conversion const&, swift::Lowering::SGFContext, llvm::function_ref<swift::Lowering::ManagedValue (swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::SGFContext)>) + 492
11 swift                    0x000000010e32fe7c (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 4124
12 swift                    0x000000010e3175b5 (anonymous namespace)::ArgEmitter::emitSingleArg(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 181
13 swift                    0x000000010e32ec8e (anonymous namespace)::ArgEmitter::emitPreparedArgs(swift::Lowering::PreparedArguments&&, swift::Lowering::AbstractionPattern) + 238
14 swift                    0x000000010e337e35 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, llvm::Optional<swift::ForeignErrorConvention> const&, swift::ImportAsMemberStatus, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::Optional<swift::SILLocation>&) + 949
15 swift                    0x000000010e31db8f (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 3935
16 swift                    0x000000010e31ad4c swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 2652
17 swift                    0x000000010e38f329 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 73
18 swift                    0x000000010e382a27 swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 871
19 swift                    0x000000010e407b3f swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 447
20 swift                    0x000000010e409571 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 7153
21 swift                    0x000000010e407b07 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 391
22 swift                    0x000000010e409571 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 7153
23 swift                    0x000000010e407b07 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 391
24 swift                    0x000000010e409571 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 7153
25 swift                    0x000000010e407b07 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 391
26 swift                    0x000000010e3b0144 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 548
27 swift                    0x000000010e303ebc swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 1388
28 swift                    0x000000010e419e8e swift::ASTVisitor<(anonymous namespace)::SILGenType, void, void, void, void, void, void>::visit(swift::Decl*) + 270
29 swift                    0x000000010e41524b (anonymous namespace)::SILGenType::emitType() + 203
30 swift                    0x000000010e30e8b2 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 82
31 swift                    0x000000010e30cbd9 (anonymous namespace)::SILGenModuleRAII::emitSourceFile(swift::SourceFile*) + 1417
32 swift                    0x000000010e30c599 swift::SILGenSourceFileRequest::evaluate(swift::Evaluator&, swift::SILGenDescriptor) const + 137
33 swift                    0x000000010e407461 swift::SimpleRequest<swift::SILGenSourceFileRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> > (swift::SILGenDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::SILGenSourceFileRequest const&, swift::Evaluator&) + 33
34 swift                    0x000000010e3133cc llvm::Expected<swift::SILGenSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::SILGenSourceFileRequest>(swift::SILGenSourceFileRequest const&) + 972
35 swift                    0x000000010e30e42d swift::performSILGeneration(swift::FileUnit&, swift::Lowering::TypeConverter&, swift::SILOptions const&) + 173
36 swift                    0x000000010de7d83f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 20479
37 swift                    0x000000010ddfec07 main + 1255
38 libdyld.dylib            0x00007fff6afaacc9 start + 1
error: Segmentation fault: 11 (in target 'PstReaderTests' from project 'PstReader')
@typesanitizer
Copy link

@typesanitizer typesanitizer commented Oct 30, 2020

@swift-ci create

@beccadax
Copy link
Contributor

@beccadax beccadax commented Nov 2, 2020

In the 10/29 development snapshot, we trip an assertion for running out of closure discriminators:

Assertion failed: (discriminator != InvalidDiscriminator), function setDiscriminator, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/include/swift/AST/Expr.h, line 3604.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
[snip]
1.  Apple Swift version 5.3-dev (LLVM 6df6611ced20c9f, Swift 142b7267089e96d)
2.  While evaluating request TypeCheckSourceFileRequest(source_file "/Users/brent/Downloads/PstReader-Segfault-example/Tests/PstReaderTests/FullDumpTests.swift")
3.  While evaluating request TypeCheckFunctionBodyRequest(PstReaderTests.(file).FullDumpTests.testOst()@/Users/brent/Downloads/PstReader-Segfault-example/Tests/PstReaderTests/FullDumpTests.swift:14:10)
0  swift-frontend           0x000000010f8c5705 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift-frontend           0x000000010f8c4965 llvm::sys::RunSignalHandlers() + 85
2  swift-frontend           0x000000010f8c5cd6 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff6d3a5d7d _sigtramp + 29
4  swift-frontend           0x0000000112467438 cmark_strbuf__initbuf + 200307
5  libsystem_c.dylib        0x00007fff6d25f520 abort + 120
6  libsystem_c.dylib        0x00007fff6d25e7d6 err + 0
7  swift-frontend           0x000000010fd473b3 (anonymous namespace)::ContextualizeClosures::walkToExprPre(swift::Expr*) (.cold.7) + 35
8  swift-frontend           0x000000010c00c301 (anonymous namespace)::ContextualizeClosures::walkToExprPre(swift::Expr*) + 753
9  swift-frontend           0x000000010c25a7bf swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 4863
10 swift-frontend           0x000000010c25b91f (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 207
11 swift-frontend           0x000000010c25bacb swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 219
12 swift-frontend           0x000000010c25bc7c swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 652
13 swift-frontend           0x000000010c25bb5f swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 367

The invalid discriminator is 0xFFFF, so discriminators currently max out at 16 bits. By my count, we are currently using no more than 11 bits of the Bits field of AbstractClosureExpr and its subclasses, so we could expand this to 21 bits without any other changes if we wanted to, or move the discriminator into a separate 32- or 64-bit field.

hughbe (JIRA User), as a workaround, try to avoid having more than 2^16-1 closures or autoclosures in a single function.

@typesanitizer
Copy link

@typesanitizer typesanitizer commented Mar 5, 2021

After some discussion with Becca, here's a breakdown of what is going on here:

1. We have a total of 64-bits available for storing information, regardless of whether the host is 32-bit or 64-bit. This is indicated by the uint64_t OpaqueBits in Expr.h.
2. Out of that, currently NumExprBits = 9 are being used by Expr. So 64 - NumExprBits are available to subclasses. As an example, CollectionExpr is using those 64 - NumExprBits bits.
3. AbstractClosureExpr is currently using 18 bits (16 for the discriminator, and it has two subclasses AutoClosureExpr and AbstractClosureExpr which take a maximum of 2 bits between them) for useful things, and 16 - NumExprBits for padding. This adds up to a total of 34 - NumExprBits.
4. Recall from 2. that we have 64 - NumExprBits available; but AbstractClosureExpr is only using 34 - NumExprBits. So there's still 30 bits worth of free real estate.
5. Suggested fix: I think we should expand the Discriminator bit-field to be a full 32-bits and remove the "InvalidDiscriminator" code entirely. We should add a matching test case to the validation test suite to make sure the compiler doesn't crash after the fix (not the usual one, since this is a somewhat pathological case and will probably take some time to run).

One unfortunate consequence of this is that we can't align the Discriminator to a 4-byte boundary without changing way too much code. I think that's okay. We can leave the padding 16 - NumExprBits as-is (so the Discriminator will be 32-bits but aligned at a 2-byte boundary instead of 4). That still leaves 16 bits for the children, which is more than enough.

Understanding what's going is somewhat tricky, but I suspect the fix will likely take < 50 LoC worth of changes. I think someone can potentially tackle this as a somewhat ambitious StarterBug.

Please feel free to ask questions here; the bit-field macro soup can be a bit of a headache to understand.

Work style notes: It may be helpful to come up with a minimal test case before making the change and make sure it hits the assert (maybe make a middle commit here marking the test as XFAIL); and then fix the code and make sure the test passes. Iterating on this change will take time as you'll be modifying widely-used headers a fair bit, so a lot of code will need to be recompiled whenever you make a change.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants