Uploaded image for project: 'Swift'
  1. Swift
  2. SR-14253

5.4 crasher when compiling NIO: TypeCheckAvailability.cpp:2939 Assertion `!Where.isImplicit()' failed

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Labels:

      Description

      when trying to compile NIO with the 5.4 nightlies, we hit this crash

      17:25:33 swift-frontend: /home/build-user/swift/lib/Sema/TypeCheckAvailability.cpp:2939: bool swift::diagnoseDeclAvailability(const swift::ValueDecl *, swift::SourceRange, const swift::ApplyExpr *, const swift::ExportContext &, swift::DeclAvailabilityFlags): Assertion `!Where.isImplicit()' failed.
      17:25:33 Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
      17:25:33 Stack dump:
      17:25:33 0.	Program arguments: /usr/bin/swift-frontend -frontend -c /code/Tests/NIOHTTP1Tests/ByteBufferUtilsTest+XCTest.swift /code/Tests/NIOHTTP1Tests/ByteBufferUtilsTest.swift /code/Tests/NIOHTTP1Tests/HTTPClientUpgradeTests+XCTest.swift /code/Tests/NIOHTTP1Tests/HTTPClientUpgradeTests.swift /code/Tests/NIOHTTP1Tests/HTTPDecoderLengthTest+XCTest.swift /code/Tests/NIOHTTP1Tests/HTTPDecoderLengthTest.swift /code/Tests/NIOHTTP1Tests/HTTPDecoderTest+XCTest.swift /code/Tests/NIOHTTP1Tests/HTTPDecoderTest.swift /code/Tests/NIOHTTP1Tests/HTTPHeadersTest+XCTest.swift /code/Tests/NIOHTTP1Tests/HTTPHeadersTest.swift /code/Tests/NIOHTTP1Tests/HTTPRequestEncoderTest+XCTest.swift /code/Tests/NIOHTTP1Tests/HTTPRequestEncoderTest.swift /code/Tests/NIOHTTP1Tests/HTTPResponseEncoderTest+XCTest.swift /code/Tests/NIOHTTP1Tests/HTTPResponseEncoderTest.swift /code/Tests/NIOHTTP1Tests/HTTPResponseStatusTests+XCTest.swift /code/Tests/NIOHTTP1Tests/HTTPResponseStatusTests.swift /code/Tests/NIOHTTP1Tests/HTTPServerClientTest+XCTest.swift /code/Tests/NIOHTTP1Tests/HTTPServerClientTest.swift /code/Tests/NIOHTTP1Tests/HTTPServerPipelineHandlerTest+XCTest.swift /code/Tests/NIOHTTP1Tests/HTTPServerPipelineHandlerTest.swift -primary-file /code/Tests/NIOHTTP1Tests/HTTPServerProtocolErrorHandlerTest+XCTest.swift -primary-file /code/Tests/NIOHTTP1Tests/HTTPServerProtocolErrorHandlerTest.swift -primary-file /code/Tests/NIOHTTP1Tests/HTTPServerUpgradeTests+XCTest.swift -primary-file /code/Tests/NIOHTTP1Tests/HTTPServerUpgradeTests.swift /code/Tests/NIOHTTP1Tests/HTTPTest+XCTest.swift /code/Tests/NIOHTTP1Tests/HTTPTest.swift /code/Tests/NIOHTTP1Tests/HTTPTypesTest+XCTest.swift /code/Tests/NIOHTTP1Tests/HTTPTypesTest.swift /code/Tests/NIOHTTP1Tests/NIOHTTPObjectAggregatorTest+XCTest.swift /code/Tests/NIOHTTP1Tests/NIOHTTPObjectAggregatorTest.swift /code/Tests/NIOHTTP1Tests/TestUtils.swift -supplementary-output-file-map /tmp/supplementaryOutputs-f30de7 -target x86_64-unknown-linux-gnu -disable-objc-interop -I /code/.build/x86_64-unknown-linux-gnu/debug -enable-testing -g -module-cache-path /code/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -warnings-as-errors -sanitize=thread -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -enable-anonymous-context-mangled-names -Xcc -fmodule-map-file=/code/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -I -Xcc /code/Sources/CNIOHTTPParser/include -Xcc -fmodule-map-file=/code/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -I -Xcc /code/Sources/CNIOAtomics/include -Xcc -fmodule-map-file=/code/Sources/CNIOWindows/include/module.modulemap -Xcc -I -Xcc /code/Sources/CNIOWindows/include -Xcc -fmodule-map-file=/code/.build/x86_64-unknown-linux-gnu/debug/CNIODarwin.build/module.modulemap -Xcc -I -Xcc /code/Sources/CNIODarwin/include -Xcc -fmodule-map-file=/code/.build/x86_64-unknown-linux-gnu/debug/CNIOLinux.build/module.modulemap -Xcc -I -Xcc /code/Sources/CNIOLinux/include -parse-as-library -module-name NIOHTTP1Tests -o /code/.build/x86_64-unknown-linux-gnu/debug/NIOHTTP1Tests.build/HTTPServerProtocolErrorHandlerTest+XCTest.swift.o -o /code/.build/x86_64-unknown-linux-gnu/debug/NIOHTTP1Tests.build/HTTPServerProtocolErrorHandlerTest.swift.o -o /code/.build/x86_64-unknown-linux-gnu/debug/NIOHTTP1Tests.build/HTTPServerUpgradeTests+XCTest.swift.o -o /code/.build/x86_64-unknown-linux-gnu/debug/NIOHTTP1Tests.build/HTTPServerUpgradeTests.swift.o -index-store-path /code/.build/x86_64-unknown-linux-gnu/debug/index/store -index-system-modules 
      17:25:33 1.	Swift version 5.4-dev (LLVM b6e6f458bb01f1f, Swift 53cfe019c0ce26d)
      17:25:33 2.	While evaluating request TypeCheckSourceFileRequest(source_file "/code/Tests/NIOHTTP1Tests/HTTPServerUpgradeTests.swift")
      17:25:33 3.	While evaluating request TypeCheckFunctionBodyRequest(NIOHTTP1Tests.(file).HTTPServerUpgradeTestCase.testChainsDelayedUpgradesAppropriately()@/code/Tests/NIOHTTP1Tests/HTTPServerUpgradeTests.swift:862:10)
      17:25:33 4.	While type-checking statement at [/code/Tests/NIOHTTP1Tests/HTTPServerUpgradeTests.swift:862:58 - line:924:5] RangeText="{
      17:25:33         enum No: Error {
      17:25:33             case no
      17:25:33         }
      17:25:33 
      17:25:33         let channel = EmbeddedChannel()
      17:25:33         defer {
      17:25:33             do {
      17:25:33                 let complete = try channel.finish()
      17:25:33                 XCTAssertTrue(complete.isClean)
      17:25:33             } catch No.no {
      17:25:33                 // ok
      17:25:33             } catch {
      17:25:33                 XCTFail("Unexpected error: \(error)")
      17:25:33             }
      17:25:33         }
      17:25:33 
      17:25:33         var upgradingProtocol = ""
      17:25:33 
      17:25:33         let failingProtocolPromise = channel.eventLoop.makePromise(of: Void.self)
      17:25:33         let failingProtocolUpgrader = UpgradeResponseDelayer(forProtocol: "failingProtocol") {
      17:25:33             XCTAssertEqual(upgradingProtocol, "")
      17:25:33             upgradingProtocol = "failingProtocol"
      17:25:33             return failingProtocolPromise.futureResult
      17:25:33         }
      17:25:33 
      17:25:33         let myprotoPromise = channel.eventLoop.makePromise(of: Void.self)
      17:25:33         let myprotoUpgrader = UpgradeResponseDelayer(forProtocol: "myproto") {
      17:25:33             XCTAssertEqual(upgradingProtocol, "failingProtocol")
      17:25:33             upgradingProtocol = "myproto"
      17:25:33             return myprotoPromise.futureResult
      17:25:33         }
      17:25:33 
      17:25:33         XCTAssertNoThrow(try channel.pipeline.configureHTTPServerPipeline(withServerUpgrade: (upgraders: [myprotoUpgrader, failingProtocolUpgrader], completionHandler: { context in })).wait())
      17:25:33 
      17:25:33         // Let's send in an upgrade request.
      17:25:33         let request = "OPTIONS * HTTP/1.1\r\nHost: localhost\r\nUpgrade: failingProtocol, myproto\r\nKafkaesque: yup\r\nConnection: upgrade\r\nConnection: kafkaesque\r\n\r\n"
      17:25:33         XCTAssertNoThrow(try channel.writeInbound(channel.allocator.buffer(string: request)))
      17:25:33 
      17:25:33         // Upgrade has been requested but not proceeded for the failing protocol.
      17:25:33         XCTAssertEqual(upgradingProtocol, "failingProtocol")
      17:25:33         XCTAssertNoThrow(try channel.pipeline.assertContainsUpgrader())
      17:25:33         XCTAssertNoThrow(XCTAssertNil(try channel.readOutbound(as: ByteBuffer.self)))
      17:25:33         XCTAssertNoThrow(try channel.throwIfErrorCaught())
      17:25:33 
      17:25:33         // Ok, now we'll fail the promise. This will catch an error, but the upgrade won't happen: instead, the second handler will be fired.
      17:25:33         failingProtocolPromise.fail(No.no)
      17:25:33         XCTAssertEqual(upgradingProtocol, "myproto")
      17:25:33         XCTAssertNoThrow(try channel.pipeline.assertContainsUpgrader())
      17:25:33         XCTAssertNoThrow(XCTAssertNil(try channel.readOutbound(as: ByteBuffer.self)))
      17:25:33         
      17:25:33         XCTAssertThrowsError(try channel.throwIfErrorCaught()) { error in
      17:25:33             XCTAssertEqual(.no, error as? No)
      17:25:33         }
      17:25:33 
      17:25:33         // Ok, now we can upgrade. Upgrader should be out of the pipeline, and we should have seen the 101 response.
      17:25:33         myprotoPromise.succeed(())
      17:25:33         channel.embeddedEventLoop.run()
      17:25:33         XCTAssertNoThrow(try channel.pipeline.assertDoesNotContainUpgrader())
      17:25:33         assertResponseIs(response: try channel.readAllOutboundString(),
      17:25:33                          expectedResponseLine: "HTTP/1.1 101 Switching Protocols",
      17:25:33                          expectedResponseHeaders: ["X-Upgrade-Complete: true", "upgrade: myproto", "connection: upgrade"])
      17:25:33     "
      17:25:33 5.	While type-checking statement at [/code/Tests/NIOHTTP1Tests/HTTPServerUpgradeTests.swift:868:9 - line:877:9] RangeText="defer {
      17:25:33             do {
      17:25:33                 let complete = try channel.finish()
      17:25:33                 XCTAssertTrue(complete.isClean)
      17:25:33             } catch No.no {
      17:25:33                 // ok
      17:25:33             } catch {
      17:25:33                 XCTFail("Unexpected error: \(error)")
      17:25:33             }
      17:25:33         "
      17:25:33 6.	While type-checking '$defer()' (in module 'NIOHTTP1Tests')
      17:25:33 7.	While evaluating request TypeCheckFunctionBodyRequest(NIOHTTP1Tests.(file).HTTPServerUpgradeTestCase.testChainsDelayedUpgradesAppropriately().$defer()@/code/Tests/NIOHTTP1Tests/HTTPServerUpgradeTests.swift:868:9)
      17:25:33 8.	While type-checking statement at [/code/Tests/NIOHTTP1Tests/HTTPServerUpgradeTests.swift:868:15 - line:877:9] RangeText="{
      17:25:33             do {
      17:25:33                 let complete = try channel.finish()
      17:25:33                 XCTAssertTrue(complete.isClean)
      17:25:33             } catch No.no {
      17:25:33                 // ok
      17:25:33             } catch {
      17:25:33                 XCTFail("Unexpected error: \(error)")
      17:25:33             }
      17:25:33         "
      17:25:33 9.	While type-checking statement at [/code/Tests/NIOHTTP1Tests/HTTPServerUpgradeTests.swift:869:13 - line:876:13] RangeText="do {
      17:25:33                 let complete = try channel.finish()
      17:25:33                 XCTAssertTrue(complete.isClean)
      17:25:33             } catch No.no {
      17:25:33                 // ok
      17:25:33             } catch {
      17:25:33                 XCTFail("Unexpected error: \(error)")
      17:25:33             "
      17:25:33 /usr/bin/swift-frontend[0x55e6a44]
      17:25:33 /usr/bin/swift-frontend[0x55e463e]
      17:25:33 /usr/bin/swift-frontend[0x55e6c25]
      17:25:33 /lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0)[0x7fcad99ef3c0]
      17:25:33 /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb)[0x7fcad949718b]
      17:25:33 /lib/x86_64-linux-gnu/libc.so.6(abort+0x12b)[0x7fcad9476859]
      17:25:33 /lib/x86_64-linux-gnu/libc.so.6(+0x25729)[0x7fcad9476729]
      17:25:33 /lib/x86_64-linux-gnu/libc.so.6(+0x36f36)[0x7fcad9487f36]
      17:25:33 /usr/bin/swift-frontend[0x143d7e7]
      17:25:33 /usr/bin/swift-frontend[0x1443b59]
      17:25:33 /usr/bin/swift-frontend[0x1443a7d]
      17:25:33 /usr/bin/swift-frontend[0x1952769]
      17:25:33 /usr/bin/swift-frontend[0x1443a13]
      17:25:33 /usr/bin/swift-frontend[0x1956720]
      17:25:33 /usr/bin/swift-frontend[0x195654d]
      17:25:33 /usr/bin/swift-frontend[0x1955f90]
      17:25:33 /usr/bin/swift-frontend[0x19554f4]
      17:25:33 /usr/bin/swift-frontend[0x1952684]
      17:25:33 /usr/bin/swift-frontend[0x143d92f]
      17:25:33 /usr/bin/swift-frontend[0x13f63ab]
      17:25:33 /usr/bin/swift-frontend[0x15183d3]
      17:25:33 /usr/bin/swift-frontend[0x151613b]
      17:25:33 /usr/bin/swift-frontend[0x151847c]
      17:25:33 /usr/bin/swift-frontend[0x15175ef]
      17:25:33 /usr/bin/swift-frontend[0x1516a00]
      17:25:33 /usr/bin/swift-frontend[0x1a52ff3]
      17:25:33 /usr/bin/swift-frontend[0x1a52d39]
      17:25:33 /usr/bin/swift-frontend[0x19b00db]
      17:25:33 /usr/bin/swift-frontend[0x19b0092]
      17:25:33 /usr/bin/swift-frontend[0x14934b9]
      17:25:33 /usr/bin/swift-frontend[0x148d3b1]
      17:25:33 /usr/bin/swift-frontend[0x148d2e1]
      17:25:33 /usr/bin/swift-frontend[0x1518501]
      17:25:33 /usr/bin/swift-frontend[0x15183bf]
      17:25:33 /usr/bin/swift-frontend[0x151613b]
      17:25:33 /usr/bin/swift-frontend[0x151847c]
      17:25:33 /usr/bin/swift-frontend[0x15175ef]
      17:25:33 /usr/bin/swift-frontend[0x1516a00]
      17:25:33 /usr/bin/swift-frontend[0x1a52ff3]
      17:25:33 /usr/bin/swift-frontend[0x1a52d39]
      17:25:33 /usr/bin/swift-frontend[0x19b00db]
      17:25:33 /usr/bin/swift-frontend[0x19b0092]
      17:25:33 /usr/bin/swift-frontend[0x154b53d]
      17:25:33 /usr/bin/swift-frontend[0x154c6df]
      17:25:33 /usr/bin/swift-frontend[0x154c445]
      17:25:33 /usr/bin/swift-frontend[0x154b248]
      17:25:33 /usr/bin/swift-frontend[0x154b224]
      17:25:33 /usr/bin/swift-frontend[0x69691a]
      17:25:33 /usr/bin/swift-frontend[0x6967e6]
      17:25:33 /usr/bin/swift-frontend[0x50c862]
      17:25:33 /usr/bin/swift-frontend[0x49cb51]
      17:25:33 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0x7fcad94780b3]
      17:25:33 /usr/bin/swift-frontend[0x49c66e]
      

      Repro

      git clone https://github.com/apple/swift-nio
      git reset --hard 6d3ca7e54e06a69d0f2612c2ce8bb8b7319085a4 # current 'main'
      swift build --build-tests
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            jw Johannes Weiss
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: