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-9514] compiler crash when compiling NIO tests (tuple_expr element type mismatch) #51966

Closed
weissi opened this issue Dec 14, 2018 · 6 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

Comments

@weissi
Copy link
Member

weissi commented Dec 14, 2018

Previous ID SR-9514
Radar rdar://problem/46742002
Original Reporter @weissi
Type Bug
Status Resolved
Resolution Done
Environment
Apple Swift version 5.0-dev (LLVM f0eaafaa71, Clang f8aee5e310, Swift b490a2a83f)
Target: x86_64-apple-darwin18.2.0
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee @slavapestov
Priority Medium

md5: d1939a9eb8ffe234ebdd474624f70991

Issue Description:

Description

when building NIO's test suite with the Swift 5.0 snapshot from 13th Dec 2018, you'll get this compiler crash

$ swift build --build-tests
tuple_expr element type mismatch:
  field: (AnyObject?)
  element: (Channel?)
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-5.0-DEVELOPMENT-SNAPSHOT-2018-12-13-a.xctoolchain/usr/bin/swift -frontend -c /Users/johannes/devel/swift-nio/Tests/NIOTests/AcceptBackoffHandlerTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/AcceptBackoffHandlerTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/BaseObjectsTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/BaseObjectsTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/BlockingIOThreadPoolTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/BlockingIOThreadPoolTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/BootstrapTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/BootstrapTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/ByteBufferTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/ByteBufferTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/ChannelNotificationTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/ChannelNotificationTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/ChannelOptionStorageTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/ChannelOptionStorageTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/ChannelPipelineTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/ChannelPipelineTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/ChannelTests+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/ChannelTests.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/CircularBufferTests+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/CircularBufferTests.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/CodecTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/CodecTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/CompositeErrorTests+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/CompositeErrorTests.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/CustomChannelTests+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/CustomChannelTests.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/DatagramChannelTests+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/DatagramChannelTests.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/EchoServerClientTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/EchoServerClientTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/EmbeddedChannelTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/EmbeddedChannelTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/EmbeddedEventLoopTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/EmbeddedEventLoopTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/EventLoopFutureTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/EventLoopFutureTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/EventLoopTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/EventLoopTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/FileRegionTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/FileRegionTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/GetAddrInfoResolverTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/GetAddrInfoResolverTest.swift -primary-file /Users/johannes/devel/swift-nio/Tests/NIOTests/HappyEyeballsTest+XCTest.swift -primary-file /Users/johannes/devel/swift-nio/Tests/NIOTests/HappyEyeballsTest.swift -primary-file /Users/johannes/devel/swift-nio/Tests/NIOTests/HeapTests+XCTest.swift -primary-file /Users/johannes/devel/swift-nio/Tests/NIOTests/HeapTests.swift -primary-file /Users/johannes/devel/swift-nio/Tests/NIOTests/IdleStateHandlerTest+XCTest.swift -primary-file /Users/johannes/devel/swift-nio/Tests/NIOTests/IdleStateHandlerTest.swift -primary-file /Users/johannes/devel/swift-nio/Tests/NIOTests/IntegerTypesTest+XCTest.swift /Users/johannes/devel/swannes/devel/swift-nio/Tests/NIOTests/MarkedCircularBufferTests+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/MarkedCircularBufferTests.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/MulticastTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/MulticastTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/NonBlockingFileIOTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/NonBlockingFileIOTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/PendingDatagramWritesManagerTests+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/PendingDatagramWritesManagerTests.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/PriorityQueueTests+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/PriorityQueueTests.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/RecvByteBufAllocatorTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/RecvByteBufAllocatorTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/SelectorTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/SelectorTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/SocketAddressTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/SocketAddressTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/SocketChannelTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/SocketChannelTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/SocketOptionProviderTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/SocketOptionProviderTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/SystemCallWrapperHelpers.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/SystemTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/SystemTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/TestUtils.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/ThreadTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/ThreadTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/TypeAssistedChannelHandlerTests+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/TypeAssistedChannelHandlerTests.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/UtilitiesTest+XCTest.swift /Users/johannes/devel/swift-nio/Tests/NIOTests/UtilitiesTest.swift -supplementary-output-file-map /var/folders/lj/qfjqv9_x6b972r7l6f49lvmh0000gn/T/supplementaryOutputs-922668 -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Volumes/Xcode10E71_m18E159_i16E166_t16L166_w16T166_b16P4059_32bitSupport_FastSim_Boost_Linux_33GB/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I /Users/johannes/devel/swift-nio/.build/x86_64-apple-macosx/debug -I /Users/johannes/devel/swift-nio/Sources/CNIOSHA1/include -I /Users/johannes/devel/swift-nio/Sources/CNIOAtomics/include -I /Users/johannes/devel/swift-nio/Sources/CNIODarwin/include -I /Users/johannes/devel/swift-nio/Sources/CNIOLinux/include -F /Volumes/Xcode10E71_m18E159_i16E166_t16L166_w16T166_b16P4059_32bitSupport_FastSim_Boost_Linux_33GB/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /Users/johannes/devel/swift-nio/.build/x86_64-apple-macosx/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -color-diagnostics -Xcc -fmodule-map-file=/Users/johannes/devel/swift-nio/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Users/johannes/devel/swift-nio/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Users/johannes/devel/swift-nio/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Users/johannes/devel/swift-nio/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap -Xcc -fmodule-map-file=/Users/johannes/devel/swift-nio/.build/checkouts/swift-nio-zlib-support-c4b8a10c/module.modulemap -parse-as-library -module-name NIOTests -o /Users/johannes/devel/swift-nio/.build/x86_64-apple-macosx/debug/NIOTests.build/HappyEyeballsTest+XCTest.evel/swift-nio/.build/x86_64-apple-macosx/debug/NIOTests.build/HappyEyeballsTest.swift.o -o /Users/johannes/devel/swift-nio/.build/x86_64-apple-macosx/debug/NIOTests.build/HeapTests+XCTest.swift.o -o /Users/johannes/devel/swift-nio/.build/x86_64-apple-macosx/debug/NIOTests.build/HeapTests.swift.o -o /Users/johannes/devel/swift-nio/.build/x86_64-apple-macosx/debug/NIOTests.build/IdleStateHandlerTest+XCTest.swift.o -o /Users/johannes/devel/swift-nio/.build/x86_64-apple-macosx/debug/NIOTests.build/IdleStateHandlerTest.swift.o -o /Users/johannes/devel/swift-nio/.build/x86_64-apple-macosx/debug/NIOTests.build/IntegerTypesTest+XCTest.swift.o -index-store-path /Users/johannes/devel/swift-nio/.build/x86_64-apple-macosx/debug/index/store -index-system-modules 
1.  While walking into decl 'HappyEyeballsTest' (at /Users/johannes/devel/swift-nio/Tests/NIOTests/HappyEyeballsTest.swift:248:8)
2.  While walking into body of 'testDelayedChannelCreation()' (at /Users/johannes/devel/swift-nio/Tests/NIOTests/HappyEyeballsTest.swift:1076:5)
0  swift                    0x0000000110d31608 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x0000000110d30885 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x0000000110d31c12 SignalHandler(int) + 258
3  libsystem_platform.dylib 0x00007fff78d02b3d _sigtramp + 29
4  libsystem_platform.dylib 0x00007f8688be4190 _sigtramp + 267261552
5  libsystem_c.dylib        0x00007fff78bc01c9 abort + 127
6  swift                    0x000000010e3f3c7a (anonymous namespace)::Verifier::walkToExprPost(swift::Expr*) + 26602
7  swift                    0x000000010e402dc0 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 240
8  swift                    0x000000010e400c2b swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 2395
9  swift                    0x000000010e4003d3 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 259
10 swift                    0x000000010e400923 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 1619
11 swift                    0x000000010e402d9f (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 207
12 swift                    0x000000010e403027 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 359
13 swift                    0x000000010e405fdb (anonymous namespace)::Traversal::visitAbstractFunctionDecl(swift::AbstractFunctionDecl*) + 683
14 swift                    0x000000010e400258 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 216
15 swift                    0x000000010e40586b (anonymous namespace)::Traversal::visitNominalTypeDecl(swift::NominalTypeDecl*) + 459
16 swift                    0x000000010e400258 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 216
17 swift                    0x000000010e40016b swift::Decl::walk(swift::ASTWalker&) + 27
18 swift                    0x000000010e4b8f6a swift::SourceFile::walk(swift::ASTWalker&) + 170
19 swift                    0x000000010e3ec61b swift::verify(swift::SourceFile&) + 59
20 swift                    0x000000010e1ae01a swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 1386
21 swift                    0x000000010d981495 swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t) + 629
22 swift                    0x000000010d980a98 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 616
23 swift                    0x000000010d15e94d performCompile(swift::CompilerInstance&, swift::CompilerInvocationt::UnifiedStatsReporter*) + 1309
24 swift                    0x000000010d15d39d swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3021
25 swift                    0x000000010d10f2be main + 686
26 libdyld.dylib            0x00007fff78b17ed9 start + 1
27 libdyld.dylib            0x0000000000000097 start + 2270069183
<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)

the problematic line in the code is

        XCTAssertTrue((try? ourChannelFutures.first!.futureResult.wait()) === (try? channelFuture.wait()))

Reproduction

git clone https://github.com/apple/swift-nio
cd swift-nio
git reset --hard b154b1988aa0fa659a6a5edd2c92f430b27e1a7a
swift build --build-tests
@belkadan
Copy link
Contributor

cc @slavapestov, @xedin

@weissi
Copy link
Member Author

weissi commented Dec 14, 2018

please note that now on NIO master we have worked around it (https://github.com/apple/swift-nio/pull/704/files#diff-579b2e5a7d23ecf5d7c69e58a43b2c95R1117) so you will need to do

git reset --hard b154b1988aa0fa659a6a5edd2c92f430b27e1a7a

to get the code w/o the workaround.

@xedin
Copy link
Member

xedin commented Dec 14, 2018

Here is the minimal reproducer:

protocol P : class {}

class F<T> {
  func wait() throws -> T { fatalError() }
}

func bar(_ a: F<P>, _ b: F<P>) {
  _ = (try? a.wait()) === (try? b.wait())
}

@xedin
Copy link
Member

xedin commented Dec 14, 2018

Just tested with 5.0 toolchain from Dec 10th - crashes, last 4.2 toolchain - OK

@xedin
Copy link
Member

xedin commented Dec 15, 2018

I have opened PR #21338 to address this problem.

@xedin
Copy link
Member

xedin commented Dec 15, 2018

Slava has a better fix for this - #21348

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

No branches or pull requests

4 participants