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-4317] ty->hasError() && "Serializing error type" #46900

Open
dabrahams opened this issue Mar 22, 2017 · 3 comments
Open

[SR-4317] ty->hasError() && "Serializing error type" #46900

dabrahams opened this issue Mar 22, 2017 · 3 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@dabrahams
Copy link
Collaborator

Previous ID SR-4317
Radar None
Original Reporter @dabrahams
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee @DougGregor
Priority Medium

md5: 01a4103ad84a7a9790362b211874fcee

Issue Description:

$ git fetch https://github.com/dabrahams/swift refs/bugs/SR-serializing-error-type:BUG && git checkout BUG

and build the compiler for this assertion:

/Users/dave/src/s/swift/utils/build-script --distcc --skip-build-ios-device --skip-build-tvos-device --skip-build-compiler-rt --debug-swift-stdlib --skip-build-benchmarks --release --swift-stdlib-assertions --swift-stdlib-build-type=Debug --

+ mkdir -p /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert
+ env HOST_VARIABLE_macosx_x86_64__SWIFT_BENCHMARK_TARGETS=swift-benchmark-macosx-x86_64 HOST_VARIABLE_macosx_x86_64__SWIFT_RUN_BENCHMARK_TARGETS=check-swift-benchmark-macosx-x86_64 'HOST_VARIABLE_macosx_x86_64__SWIFT_SDKS=IOS IOS_SIMULATOR OSX TVOS TVOS_SIMULATOR WATCHOS WATCHOS_SIMULATOR' HOST_VARIABLE_macosx_x86_64__SWIFT_STDLIB_TARGETS=swift-test-stdlib-macosx-x86_64 HOST_VARIABLE_macosx_x86_64__SWIFT_TEST_TARGETS= caffeinate /Users/Shared/dabrahams/s/swift/utils/build-script-impl --workspace /Users/Shared/dabrahams/s --build-dir /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert --install-prefix /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr --host-target macosx-x86_64 --stdlib-deployment-targets 'macosx-x86_64 iphonesimulator-i386 iphonesimulator-x86_64 appletvsimulator-x86_64 watchsimulator-i386 iphoneos-armv7 iphoneos-armv7s iphoneos-arm64 appletvos-arm64 watchos-armv7k' --host-cc /Applications/Xcode-8W109m.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang --host-cxx /Applications/Xcode-8W109m.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ --darwin-xcrun-toolchain default --darwin-deployment-version-osx=10.9 --darwin-deployment-version-ios=7.0 --darwin-deployment-version-tvos=9.0 --darwin-deployment-version-watchos=2.0 --cmake /Users/dave/brew/bin/cmake --cmark-build-type Release --llvm-build-type Release --swift-build-type Release --swift-stdlib-build-type Debug --lldb-build-type Release --foundation-build-type Release --libdispatch-build-type Release --libicu-build-type Release --xctest-build-type Release --swiftpm-build-type Release --swift-enable-assertions true --swift-stdlib-enable-assertions true --swift-analyze-code-coverage false --cmake-generator Ninja --build-jobs 8 '--common-cmake-options=-G Ninja -DCMAKE_C_COMPILER:PATH=/Users/dave/brew/bin/distcc -DCMAKE_C_COMPILER_ARG1=/Applications/Xcode-8W109m.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -DCMAKE_CXX_COMPILER:PATH=/Users/dave/brew/bin/distcc -DCMAKE_CXX_COMPILER_ARG1=/Applications/Xcode-8W109m.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -DCMAKE_MAKE_PROGRAM=/Users/dave/brew/bin/ninja' --build-args=-j112 --cmark-cmake-options= '--llvm-cmake-options=-DLLVM_ENABLE_ASSERTIONS=TRUE -DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64;PowerPC;SystemZ' '--swift-cmake-options=-DSWIFT_STDLIB_ENABLE_SIL_OWNERSHIP=FALSE -DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE -DSWIFT_FORCE_OPTIMIZED_TYPECHECKER=FALSE' --build-stdlib-deployment-targets all --ninja-bin=/Users/dave/brew/bin/ninja --distcc --distcc-pump=/Users/dave/brew/bin/pump --skip-build-benchmarks --skip-build-foundation --skip-build-xctest --skip-build-lldb --skip-build-llbuild --skip-build-libdispatch --skip-build-libicu --skip-build-swiftpm --skip-build-playgroundlogger --skip-build-playgroundsupport --build-swift-dynamic-stdlib --build-swift-dynamic-sdk-overlay --skip-build-ios-device --skip-build-ios-simulator --skip-build-tvos-device --skip-build-tvos-simulator --skip-build-watchos-device --skip-build-watchos-simulator --skip-build-android --skip-test-swift --skip-test-cmark --skip-test-lldb --skip-test-llbuild --skip-test-swiftpm --skip-test-xctest --skip-test-foundation --skip-test-libdispatch --skip-test-libicu --skip-test-playgroundlogger --skip-test-playgroundsupport --skip-test-linux --skip-test-freebsd --skip-test-cygwin --skip-test-osx --skip-test-ios-host --skip-test-ios-simulator --skip-test-tvos-host --skip-test-tvos-simulator --skip-test-watchos-host --skip-test-watchos-simulator --skip-test-android-host --skip-test-benchmarks --skip-test-optimized --android-deploy-device-path /data/local/tmp --toolchain-prefix /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain --host-lipo /Applications/Xcode-8W109m.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo --host-libtool /Applications/Xcode-8W109m.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool --skip-build-compiler-rt --swift-stdlib-build-type=Debug --llvm-lit-args=-sv
Building the standard library for: swift-test-stdlib-macosx-x86_64
cmark: using standard linker
+ /Users/dave/brew/bin/pump /Users/dave/brew/bin/cmake --build /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/cmark-macosx-x86_64 -- -j112 all
__________Using distcc-pump from /Users/dave/brew/bin/../Cellar/distcc-swift/r796/bin
__________Using       12 distcc servers in pump mode
ninja: no work to do.
__________Shutting down distcc-pump include server
llvm: using standard linker
symlinking the system headers (/Applications/Xcode-8W109m.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../../usr/include/c++) into the local clang build directory (/Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/llvm-macosx-x86_64/include).
+ ln -s -f /Applications/Xcode-8W109m.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../../usr/include/c++ /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/llvm-macosx-x86_64/include
+ /Users/dave/brew/bin/pump /Users/dave/brew/bin/cmake --build /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/llvm-macosx-x86_64 -- -j112 all
__________Using distcc-pump from /Users/dave/brew/bin/../Cellar/distcc-swift/r796/bin
__________Using       12 distcc servers in pump mode
ninja: no work to do.
__________Shutting down distcc-pump include server
swift: using standard linker
+ /Users/dave/brew/bin/pump /Users/dave/brew/bin/cmake --build /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64 -- -j112 all swift-test-stdlib-macosx-x86_64
__________Using distcc-pump from /Users/dave/brew/bin/../Cellar/distcc-swift/r796/bin
__________Using       12 distcc servers in pump mode
[1/153] Generating ForwardingWrapper.swift from ForwardingWrapper.swift.gyb with ptr size = 8
[2/153] Generating /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/./lib/swift/macosx/x86_64/Swift.swiftmodule
FAILED: lib/swift/macosx/x86_64/Swift.swiftmodule lib/swift/macosx/x86_64/Swift.swiftdoc 
cd /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/stdlib/public/core && /Users/dave/brew/Cellar/cmake/3.7.1/bin/cmake -E remove -f /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/./lib/swift/macosx/x86_64/Swift.swiftmodule && /usr/bin/python /Users/Shared/dabrahams/s/swift/utils/line-directive @/Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/stdlib/public/core/q7M3b.txt -- /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/./bin/swiftc -emit-module -o /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/./lib/swift/macosx/x86_64/Swift.swiftmodule -sdk /Applications/Xcode-8W109m.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -target x86_64-apple-macosx10.9 -resource-dir /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/./lib/swift -F /Applications/Xcode-8W109m.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/../../../Developer/Library/Frameworks -Onone -g -D INTERNAL_CHECKS_ENABLED -I /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/./lib/swift/macosx/x86_64 -module-cache-path /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/./module-cache -no-link-objc-runtime -nostdimport -parse-stdlib -module-name Swift -Xfrontend -group-info-path -Xfrontend /Users/Shared/dabrahams/s/swift/stdlib/public/core/GroupInfo.json -Xfrontend -sil-serialize-all -module-link-name swiftCore -force-single-frontend-invocation -Xcc -D__SWIFT_CURRENT_DYLIB=swiftCore -parse-as-library @/Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/stdlib/public/core/q7M3b.txt
Assertion failed: (!ty->hasError() && "Serializing error type"), function addTypeRef, file /Users/Shared/dabrahams/s/swift/lib/Serialization/Serialization.cpp, line 461.
0  swift                    0x000000010d69e898 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x000000010d69ef46 SignalHandler(int) + 454
2  libsystem_platform.dylib 0x00007fffbd848b3a _sigtramp + 26
3  swift                    0x000000010af991c4 void llvm::impl::BCRecordCoding<llvm::BCFixed<1u>, llvm::BCFixed<1u>, llvm::BCFixed<1u>, llvm::BCVBR<5u>, llvm::BCVBR<5u>, llvm::BCVBR<4u>, llvm::BCFixed<1u>, llvm::BCFixed<1u>, llvm::BCVBR<5u>, llvm::BCVBR<5u>, llvm::BCVBR<4u>, llvm::BCFixed<1u>, llvm::BCFixed<1u>, llvm::BCVBR<5u>, llvm::BCVBR<5u>, llvm::BCVBR<4u>, llvm::BCFixed<1u>, llvm::BCFixed<1u>, llvm::BCVBR<5u>, llvm::BCVBR<5u>, llvm::BCVBR<5u>, llvm::BCBlob>::emit<llvm::SmallVector<unsigned long long, 64u>, bool, bool, bool, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned long, unsigned long, llvm::SmallString<32u> >(llvm::BitstreamWriter&, llvm::SmallVector<unsigned long long, 64u>&, unsigned int, bool, bool, bool, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned long, unsigned long, llvm::SmallString<32u>) + 372
4  libsystem_c.dylib        0x00007fffbd6cd420 abort + 129
5  libsystem_c.dylib        0x00007fffbd694893 basename_r + 0
6  swift                    0x000000010af6cee6 swift::serialization::Serializer::addTypeRef(swift::Type) + 406
7  swift                    0x000000010af7b08f swift::serialization::Serializer::writeDecl(swift::Decl const*) + 9839
8  swift                    0x000000010af81466 swift::serialization::Serializer::writeAllDeclsAndTypes() + 3078
9  swift                    0x000000010af826e8 swift::serialization::Serializer::writeAST(llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, bool) + 3224
10 swift                    0x000000010af8708b swift::serialization::Serializer::writeToStream(llvm::raw_ostream&, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::SILModule const*, swift::SerializationOptions const&) + 139
11 swift                    0x000000010afb5f73 void llvm::function_ref<void (llvm::raw_ostream&)>::callback_fn<swift::serialize(llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::SerializationOptions const&, swift::SILModule const*)::$_5>(long, llvm::raw_ostream&) + 179
12 swift                    0x000000010af8821b withOutputFile(swift::ASTContext&, llvm::StringRef, llvm::function_ref<void (llvm::raw_ostream&)>) + 395
13 swift                    0x000000010af8800c swift::serialize(llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::SerializationOptions const&, swift::SILModule const*) + 220
14 swift                    0x000000010a3ab08c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 14652
15 swift                    0x000000010a365f10 main + 3312
16 libdyld.dylib            0x00007fffbd639235 start + 1
17 libdyld.dylib            0x0000000000000027 start + 1117548019
Stack dump:
0.  Program arguments: /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/bin/swift -frontend -emit-module -filelist /var/folders/k9/nzq6k4f57xb5vw8wrgk_7cvh0000gn/T/sources-da3a42 -disable-objc-attr-requires-foundation-module -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode-8W109m.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -I /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/./lib/swift/macosx/x86_64 -F /Applications/Xcode-8W109m.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/../../../Developer/Library/Frameworks -g -module-cache-path /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/./module-cache -module-link-name swiftCore -nostdimport -parse-stdlib -resource-dir /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/./lib/swift -D INTERNAL_CHECKS_ENABLED -group-info-path /Users/Shared/dabrahams/s/swift/stdlib/public/core/GroupInfo.json -sil-serialize-all -Xcc -D__SWIFT_CURRENT_DYLIB=swiftCore -emit-module-doc-path /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/./lib/swift/macosx/x86_64/Swift.swiftdoc -Onone -parse-as-library -module-name Swift -o /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/./lib/swift/macosx/x86_64/Swift.swiftmodule 
1.  While serializing type '<<error type>>'
@rudkx
Copy link
Member

rudkx commented Mar 22, 2017

Reproduced this locally. Taking a look now.

@dabrahams
Copy link
Collaborator Author

A workaround seems to be to remove the : Iterator constraint on this line, so I am no longer blocked

@rudkx
Copy link
Member

rudkx commented Mar 23, 2017

We seem to end up with ErrorType in for the type we're conforming to, but never emit a diagnostic, which means that we don't bail out after type checking, but rather continue and attempt to serialize.

(lldb) p ATD->dump()
(associated_type_decl "Iterator" interface type='Self.Iterator.Type' access=public default=Self.Base.Iterator)
(lldb) p inherited.isError()
(bool) $3 = true
(lldb) p inherited.TyR->getLoc()
(swift::SourceLoc) $2 = {
Value = (Ptr = "Iterator = Base.Iterator\n func wrap(: Base.Index) ~~> Index\n func unwrap(: Index) ~~> Base.Index\n}\n\n/// When the `Iterator` type matches, just forward it.\nextension BidirectionalCollectionWrapper where Iterator == Base.Iterator {\n public func makeIterator() ~~> Iterator { return base.makeIterator() }\n}\n\n/// When the `Index` type matches, wrapping/unwrapping is trivial\npublic extension BidirectionalCollectionWrapper where Index == Base.Index {\n func wrap( i: Base.Index) ~~> Index { return i }\n func unwrap( i: Index) ~~> Base.Index { return i }\n}\n\n/// Forwards all the `BidirectionalCollection` APIs from `Base`, verbatim, but\n/// with whatever Index wrapping we have chosen.\nextension BidirectionalCollectionWrapper {\n // ###sourceLocation(file: "/Users/mark_lacey/swift-dave/swift/stdlib/public/core/ForwardCollectionAPIs.swift.gyb", line: 1)\n//===~~~~~~ ForwardCollectionAPIs.swift.gyb -~~~~-------------------------------===//\n//\n// This source file is part of the Swift.org open source project\n//\n// Copyright ")

@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
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants