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-14743] Compiler Crash with Swift 5.4.1/5.5/main on Linux #57093

Closed
PSchmiedmayer opened this issue Jun 8, 2021 · 13 comments
Closed

[SR-14743] Compiler Crash with Swift 5.4.1/5.5/main on Linux #57093

PSchmiedmayer opened this issue Jun 8, 2021 · 13 comments
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 regression swift 5.4

Comments

@PSchmiedmayer
Copy link

Previous ID SR-14743
Radar None
Original Reporter @PSchmiedmayer
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Environment

Swift version 5.4.1 (swift-5.4.1-RELEASE)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 5.4Regression, 5.5Regression, CompilerCrash
Assignee None
Priority Medium

md5: 266c7db5493fbd8ee70a23c0557b75ed

duplicates:

  • SR-14680 Compiler crash during verification of SIL function (Linux only)

Issue Description:

Dear Swift compiler team, dear Swift open source community,

while updating a Server-Side Swift package to Swift 5.4 (Apodini/Apodini#294 I have noted that a dependency of the project (OpenAPIKit) fails to compile on Swift 5.4 on Linux resulting in a compiler crash.

The compiler crashes with the error log attached below.
You can reproduce the error as follows:

  1. Clone the OpenAPIKit repo (OpenAPIKit) to your machine

  2. Open your terminal and navigate in the root OpenAPIKit folder you cloned the repo in

  3. Start up a docker container with the latest Swift docker image and mount the folder in the docker container: `docker run -ti -v $(pwd):/OpenAPIKit swift`

  4. After the image is pulled you can execute commands in the Docker image. `cd` in the `OpenAPIKit` folder and run `swift build`

You receive the following error log and a hint to create a bug report on bugs.swift.org: ErrorLog.txt

These are the last lines of the error log:

Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0.  Program arguments: /usr/bin/swift-frontend -frontend -c /OpenAPIKit/Sources/OpenAPIKit/AnyCodable/AnyCodable.swift /OpenAPIKit/Sources/OpenAPIKit/Callbacks.swift /OpenAPIKit/Sources/OpenAPIKit/CodableVendorExtendable.swift /OpenAPIKit/Sources/OpenAPIKit/Components Object/Components+JSONReference.swift /OpenAPIKit/Sources/OpenAPIKit/Components Object/Components+Locatable.swift /OpenAPIKit/Sources/OpenAPIKit/Components Object/Components.swift /OpenAPIKit/Sources/OpenAPIKit/Content/Content.swift /OpenAPIKit/Sources/OpenAPIKit/Content/ContentEncoding.swift /OpenAPIKit/Sources/OpenAPIKit/Content/ContentType.swift /OpenAPIKit/Sources/OpenAPIKit/Content/DereferencedContent.swift /OpenAPIKit/Sources/OpenAPIKit/Content/DereferencedContentEncoding.swift /OpenAPIKit/Sources/OpenAPIKit/Discriminator.swift /OpenAPIKit/Sources/OpenAPIKit/Document/DereferencedDocument.swift /OpenAPIKit/Sources/OpenAPIKit/Document/Document.swift /OpenAPIKit/Sources/OpenAPIKit/Document/DocumentInfo.swift /OpenAPIKit/Sources/OpenAPIKit/Document/ResolvedDocument.swift /OpenAPIKit/Sources/OpenAPIKit/Either/Either+Codable.swift /OpenAPIKit/Sources/OpenAPIKit/Either/Either+Convenience.swift /OpenAPIKit/Sources/OpenAPIKit/Either/Either+CustomStringConvertible.swift /OpenAPIKit/Sources/OpenAPIKit/Either/Either.swift /OpenAPIKit/Sources/OpenAPIKit/Encoding and Decoding Errors/DecodingErrorExtensions.swift /OpenAPIKit/Sources/OpenAPIKit/Encoding and Decoding Errors/DiggingError.swift /OpenAPIKit/Sources/OpenAPIKit/Encoding and Decoding Errors/DocumentDecodingError.swift /OpenAPIKit/Sources/OpenAPIKit/Encoding and Decoding Errors/EitherDecodeNoTypesMatchedErrorExtensions.swift /OpenAPIKit/Sources/OpenAPIKit/Encoding and Decoding Errors/InconsistencyError.swift /OpenAPIKit/Sources/OpenAPIKit/Encoding and Decoding Errors/OpenAPIDecodingErrors.swift /OpenAPIKit/Sources/OpenAPIKit/Encoding and Decoding Errors/OpenAPIError.swift /OpenAPIKit/Sources/OpenAPIKit/Encoding and Decoding Errors/OperationDecodingError.swift /OpenAPIKit/Sources/OpenAPIKit/Encoding and Decoding Errors/PathDecodingError.swift /OpenAPIKit/Sources/OpenAPIKit/Encoding and Decoding Errors/RequestDecodingError.swift /OpenAPIKit/Sources/OpenAPIKit/Encoding and Decoding Errors/ResponseDecodingError.swift /OpenAPIKit/Sources/OpenAPIKit/Example.swift /OpenAPIKit/Sources/OpenAPIKit/ExternalDocumentation.swift /OpenAPIKit/Sources/OpenAPIKit/Header/DereferencedHeader.swift /OpenAPIKit/Sources/OpenAPIKit/Header/Header.swift /OpenAPIKit/Sources/OpenAPIKit/HttpMethod.swift /OpenAPIKit/Sources/OpenAPIKit/JSONReference.swift /OpenAPIKit/Sources/OpenAPIKit/Link.swift /OpenAPIKit/Sources/OpenAPIKit/OpenAPI.swift /OpenAPIKit/Sources/OpenAPIKit/Operation/DereferencedOperation.swift /OpenAPIKit/Sources/OpenAPIKit/Operation/Operation.swift /OpenAPIKit/Sources/OpenAPIKit/Operation/ResolvedEndpoint.swift /OpenAPIKit/Sources/OpenAPIKit/OrderedDictionary/OrderedDictionary.swift /OpenAPIKit/Sources/OpenAPIKit/OrderedDictionary/StringConvertibleHintProvider.swift /OpenAPIKit/Sources/OpenAPIKit/Parameter/DereferencedParameter.swift /OpenAPIKit/Sources/OpenAPIKit/Parameter/DereferencedSchemaContext.swift /OpenAPIKit/Sources/OpenAPIKit/Parameter/Parameter.swift /OpenAPIKit/Sources/OpenAPIKit/Parameter/ParameterContext.swift /OpenAPIKit/Sources/OpenAPIKit/Parameter/ParameterSchemaContext.swift /OpenAPIKit/Sources/OpenAPIKit/Path Item/DereferencedPathItem.swift /OpenAPIKit/Sources/OpenAPIKit/Path Item/PathItem.swift /OpenAPIKit/Sources/OpenAPIKit/Path Item/ResolvedRoute.swift /OpenAPIKit/Sources/OpenAPIKit/Request/DereferencedRequest.swift /OpenAPIKit/Sources/OpenAPIKit/Request/Request.swift /OpenAPIKit/Sources/OpenAPIKit/Response/DereferencedResponse.swift -primary-file /OpenAPIKit/Sources/OpenAPIKit/Response/Response.swift -primary-file /OpenAPIKit/Sources/OpenAPIKit/RuntimeExpression.swift -primary-file /OpenAPIKit/Sources/OpenAPIKit/Schema Conformances/SchemaProtocols.swift -primary-file /OpenAPIKit/Sources/OpenAPIKit/Schema Conformances/SwiftPrimitiveTypes+OpenAPI.swift -primary-file /OpenAPIKit/Sources/OpenAPIKit/Schema Object/DereferencedJSONSchema.swift -primary-file /OpenAPIKit/Sources/OpenAPIKit/Schema Object/JSONSchema+Combining.swift -primary-file /OpenAPIKit/Sources/OpenAPIKit/Schema Object/JSONSchema.swift -primary-file /OpenAPIKit/Sources/OpenAPIKit/Schema Object/JSONSchemaContext.swift -primary-file /OpenAPIKit/Sources/OpenAPIKit/Schema Object/SimplifiedJSONSchema.swift -primary-file /OpenAPIKit/Sources/OpenAPIKit/Schema Object/TypesAndFormats.swift -primary-file /OpenAPIKit/Sources/OpenAPIKit/Security/DereferencedSecurityRequirement.swift -primary-file /OpenAPIKit/Sources/OpenAPIKit/Security/OAuthFlows.swift -primary-file /OpenAPIKit/Sources/OpenAPIKit/Security/SecurityScheme.swift /OpenAPIKit/Sources/OpenAPIKit/Server.swift /OpenAPIKit/Sources/OpenAPIKit/Tag.swift /OpenAPIKit/Sources/OpenAPIKit/URLTemplate/URLTemplate+Parsing.swift /OpenAPIKit/Sources/OpenAPIKit/URLTemplate/URLTemplate.swift /OpenAPIKit/Sources/OpenAPIKit/Utility/Container+DecodeURLAsString.swift /OpenAPIKit/Sources/OpenAPIKit/Utility/Optional+Zip.swift /OpenAPIKit/Sources/OpenAPIKit/Utility/Result+Value.swift /OpenAPIKit/Sources/OpenAPIKit/Validator/Validatable.swift /OpenAPIKit/Sources/OpenAPIKit/Validator/Validation+Builtins.swift /OpenAPIKit/Sources/OpenAPIKit/Validator/Validation.swift /OpenAPIKit/Sources/OpenAPIKit/Validator/Validator+Convenience.swift /OpenAPIKit/Sources/OpenAPIKit/Validator/Validator.swift /OpenAPIKit/Sources/OpenAPIKit/XML.swift -supplementary-output-file-map /tmp/supplementaryOutputs-d5b819 -target x86_64-unknown-linux-gnu -disable-objc-interop -I /OpenAPIKit/.build/x86_64-unknown-linux-gnu/debug -color-diagnostics -enable-testing -g -module-cache-path /OpenAPIKit/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -enable-anonymous-context-mangled-names -parse-as-library -module-name OpenAPIKit -o /OpenAPIKit/.build/x86_64-unknown-linux-gnu/debug/OpenAPIKit.build/Response/Response.swift.o -o /OpenAPIKit/.build/x86_64-unknown-linux-gnu/debug/OpenAPIKit.build/RuntimeExpression.swift.o -o /OpenAPIKit/.build/x86_64-unknown-linux-gnu/debug/OpenAPIKit.build/Schema Conformances/SchemaProtocols.swift.o -o /OpenAPIKit/.build/x86_64-unknown-linux-gnu/debug/OpenAPIKit.build/Schema Conformances/SwiftPrimitiveTypes+OpenAPI.swift.o -o /OpenAPIKit/.build/x86_64-unknown-linux-gnu/debug/OpenAPIKit.build/Schema Object/DereferencedJSONSchema.swift.o -o /OpenAPIKit/.build/x86_64-unknown-linux-gnu/debug/OpenAPIKit.build/Schema Object/JSONSchema+Combining.swift.o -o /OpenAPIKit/.build/x86_64-unknown-linux-gnu/debug/OpenAPIKit.build/Schema Object/JSONSchema.swift.o -o /OpenAPIKit/.build/x86_64-unknown-linux-gnu/debug/OpenAPIKit.build/Schema Object/JSONSchemaContext.swift.o -o /OpenAPIKit/.build/x86_64-unknown-linux-gnu/debug/OpenAPIKit.build/Schema Object/SimplifiedJSONSchema.swift.o -o /OpenAPIKit/.build/x86_64-unknown-linux-gnu/debug/OpenAPIKit.build/Schema Object/TypesAndFormats.swift.o -o /OpenAPIKit/.build/x86_64-unknown-linux-gnu/debug/OpenAPIKit.build/Security/DereferencedSecurityRequirement.swift.o -o /OpenAPIKit/.build/x86_64-unknown-linux-gnu/debug/OpenAPIKit.build/Security/OAuthFlows.swift.o -o /OpenAPIKit/.build/x86_64-unknown-linux-gnu/debug/OpenAPIKit.build/Security/SecurityScheme.swift.o -index-store-path /OpenAPIKit/.build/x86_64-unknown-linux-gnu/debug/index/store -index-system-modules 
1.  Swift version 5.4.1 (swift-5.4.1-RELEASE)
2.  While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "/OpenAPIKit/Sources/OpenAPIKit/Schema Object/JSONSchema+Combining.swift")
3.  While silgen emitFunction SIL function "@$s10OpenAPIKit16FragmentCombinerV7combineyyAA10JSONSchemaOKF".
 for 'combine(_:)' (at /OpenAPIKit/Sources/OpenAPIKit/Schema Object/JSONSchema+Combining.swift:113:14)
4.  While verifying SIL function "@$s10OpenAPIKit16FragmentCombinerV7combineyyAA10JSONSchemaOKF".
 for 'combine(_:)' (at /OpenAPIKit/Sources/OpenAPIKit/Schema Object/JSONSchema+Combining.swift:113:14)
/usr/bin/swift-frontend[0x58056b4]
/usr/bin/swift-frontend[0x580314e]
/usr/bin/swift-frontend[0x580589c]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7feafa0f9980]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7feaf899bfb7]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7feaf899d921]
/usr/bin/swift-frontend[0x12e5b2d]
/usr/bin/swift-frontend[0x1302d7f]
/usr/bin/swift-frontend[0x12ea4ee]
/usr/bin/swift-frontend[0x12e89f6]
/usr/bin/swift-frontend[0x12e0d5e]
/usr/bin/swift-frontend[0x9c531e]
/usr/bin/swift-frontend[0x9c424f]
/usr/bin/swift-frontend[0x9c65c1]
/usr/bin/swift-frontend[0x9c28a2]
/usr/bin/swift-frontend[0xaa5302]
/usr/bin/swift-frontend[0xaa196b]
/usr/bin/swift-frontend[0xaa17d8]
/usr/bin/swift-frontend[0x9c90c2]
/usr/bin/swift-frontend[0xa92452]
/usr/bin/swift-frontend[0x9ce4e0]
/usr/bin/swift-frontend[0x9ca804]
/usr/bin/swift-frontend[0x51ba23]
/usr/bin/swift-frontend[0x510710]
/usr/bin/swift-frontend[0x49be53]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7feaf897ebf7]
/usr/bin/swift-frontend[0x49b96a]

I have also added additional GitHub Actions to my fork at https://github.com/PSchmiedmayer/OpenAPIKit. You can see that all Swift 5.4 related builds fail: https://github.com/PSchmiedmayer/OpenAPIKit/actions/runs/919770569.

Feel free to reach out to me if you have any follow up questions and already a huge thanks to anyone from the Swift compiler team and/or from the Swift open source community for taking a look at the issue.

@PSchmiedmayer
Copy link
Author

I have also create an issue in the OpenAPIKit repo for reference including the complete error log: mattpolzin/OpenAPIKit#224 (comment)

@PSchmiedmayer
Copy link
Author

As pointed out by Mathew Polzin (mattpolzin/OpenAPIKit#224 the following issue seems to track the same problem: https://bugs.swift.org/browse/SR-14680

@weissi
Copy link
Member

weissi commented Jun 9, 2021

@swift-ci create

@weissi
Copy link
Member

weissi commented Jun 9, 2021

Thank you! Let’s start with @gottesmm who may have an idea if we already know the root cause of this. Or if this needs further diagnosing

@PSchmiedmayer
Copy link
Author

@weissi As noted in your tweet I have checked it with the nightly builds for Swift 5.4 and Swift 5.5: https://github.com/PSchmiedmayer/OpenAPIKit/actions/runs/920890077. The build fails on the nightly builds of Swift 5.4 and Swift 5.5 as well as the nightly builds on the main branch. The builds run fine on macOS. As far as I can see it started failing with Swift 5.4, Swift 5.3 builds seem to be fine.

@weissi
Copy link
Member

weissi commented Jun 9, 2021

One-line repo

rm -rf /tmp/OpenAPIKit && cd /tmp && git clone https://github.com/mattpolzin/OpenAPIKit && cd OpenAPIKit && docker run -it --rm -v "$PWD:$PWD" -w "$PWD" swift:5.4.1 swift build

my repro with 5.5

1.  Swift version 5.5-dev (LLVM 08f96c278ca01fb, Swift b8900dedf141690)
2.  While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "/tmp/OpenAPIKit/Sources/OpenAPIKit/Schema Object/JSONSchema+Combining.swift")
3.  While silgen emitFunction SIL function "@$s10OpenAPIKit16FragmentCombinerV7combineyyAA10JSONSchemaOKF".
 for 'combine(_:)' (at /tmp/OpenAPIKit/Sources/OpenAPIKit/Schema Object/JSONSchema+Combining.swift:113:14)
4.  While verifying SIL function "@$s10OpenAPIKit16FragmentCombinerV7combineyyAA10JSONSchemaOKF".
 for 'combine(_:)' (at /tmp/OpenAPIKit/Sources/OpenAPIKit/Schema Object/JSONSchema+Combining.swift:113:14)
#​0 0x00000000052a60a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/bin/swift-frontend+0x52a60a8)

@weissi
Copy link
Member

weissi commented Jun 9, 2021

@swift-ci create

@weissi
Copy link
Member

weissi commented Jun 9, 2021

it's in the SILVerifier

(lldb) bt
* thread #​1, name = 'swift-frontend', stop reason = signal SIGABRT
  * frame #​0: 0x0000fffff7b2a138 libc.so.6`raise + 224
    frame #​1: 0x0000fffff7b16d68 libc.so.6`abort + 272
    frame #&#8203;2: 0x0000000000755448 swift-frontend`(anonymous namespace)::SILVerifier::_require(bool, llvm::Twine const&, std::function<void ()> const&) + 1488
    frame #&#8203;3: 0x000000000076b640 swift-frontend`swift::SILInstructionVisitor<(anonymous namespace)::SILVerifier, void>::visit(swift::SILInstruction*) + 70372
    frame #&#8203;4: 0x0000000000759574 swift-frontend`(anonymous namespace)::SILVerifier::visitSILBasicBlock(swift::SILBasicBlock*) + 1208
    frame #&#8203;5: 0x00000000007578b8 swift-frontend`(anonymous namespace)::SILVerifier::visitSILFunction(swift::SILFunction*) + 7832
    frame #&#8203;6: 0x00000000007511f4 swift-frontend`swift::SILFunction::verify(bool) const + 64
    frame #&#8203;7: 0x0000000000bc97bc swift-frontend`swift::Lowering::SILGenModule::postEmitFunction(swift::SILDeclRef, swift::SILFunction*) + 228
    frame #&#8203;8: 0x0000000000bc8b34 swift-frontend`swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 7020
    frame #&#8203;9: 0x0000000000bca940 swift-frontend`emitOrDelayFunction(swift::Lowering::SILGenModule&, swift::SILDeclRef, bool) + 212
    frame #&#8203;10: 0x0000000000bc6f94 swift-frontend`swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 140
    frame #&#8203;11: 0x0000000000c6a42c swift-frontend`(anonymous namespace)::SILGenType::emitType() + 216
    frame #&#8203;12: 0x0000000000c6a348 swift-frontend`swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 24
    frame #&#8203;13: 0x0000000000bccea4 swift-frontend`swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 1544
    frame #&#8203;14: 0x0000000000c5dc78 swift-frontend`swift::SimpleRequest<swift::ASTLoweringRequest, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> > (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) + 140
    frame #&#8203;15: 0x0000000000bd06f4 swift-frontend`llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 392
    frame #&#8203;16: 0x0000000000bcdba8 swift-frontend`swift::performASTLowering(swift::FileUnit&, swift::Lowering::TypeConverter&, swift::SILOptions const&) + 100
    frame #&#8203;17: 0x0000000000531f2c swift-frontend`bool llvm::function_ref<bool (swift::CompilerInstance&)>::callback_fn<performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*)::$_19>(long, swift::CompilerInstance&) + 224
    frame #&#8203;18: 0x0000000000525d98 swift-frontend`swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4960
    frame #&#8203;19: 0x0000000000487208 swift-frontend`main + 476
    frame #&#8203;20: 0x0000fffff7b17090 libc.so.6`__libc_start_main + 232
    frame #&#8203;21: 0x0000000000486e6c swift-frontend`_start + 52

CC @gottesmm

@gottesmm
Copy link
Member

gottesmm commented Jun 9, 2021

I am starting to investigate. That being said, @PSchmiedmayer I want to unblock you. Here is a work around: -Xfrontend -sil-verify-none. That should disable the verifier allowing you to build until a fix gets to you. I wouldn't enable it permanently since the verifier makes sure that the compiler is working correctly!

@weissi
Copy link
Member

weissi commented Jun 9, 2021

Nice one @gottesmm, thanks! @PSchmiedmayer to hand the suggested arguments through with SwiftPM, you'll need

swift build -Xswiftc -Xfrontend -Xswiftc -sil-verify-none YOUR-REGULAR-ARGUMENTS

@PSchmiedmayer
Copy link
Author

@weissi @gottesmm Thanks a lot for taking a look at the issue and investigating it!
And also huge thanks for the workaround, it works and I can compile OpenAPIKit as well as Apodini with that configuration. I will remove the flags as soon as a future release fixes the issue.

@gottesmm
Copy link
Member

gottesmm commented Jun 9, 2021

@PSchmiedmayer thanks![]( Don't forget since otherwise you can run into weird errors potentially. I am just glad that you are unblocked)

@PSchmiedmayer
Copy link
Author

@weissi @gottesmm Polzin (JIRA User) Is there any update on this issue?

I might come across as pushy here but I really like OpenAPIKit and think it is crucial for growing Server-Side Swift ecosystem. While the workaround is fine for now it would be great if an Swift 5.4.X patch or latest Swift 5.5 would resolve the issue so we and other maintainers can easily use and integrate the project. Otherwise the hurdle of using the project would be quite large as developers guided from the Swift Server Work Group projects page probably won't dig too deep on a first try to discover the workaround.

I am definitely not a compiler expert and am not familiar with C++ but if there is any other way I can help or assist to fix the problem I am happy to invest time and help!

@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 regression swift 5.4
Projects
None yet
Development

No branches or pull requests

4 participants