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-1951] 3 segmentation faults after migrating code to Swift 3 #44560

Closed
NachoSoto opened this issue Jun 30, 2016 · 26 comments
Closed

[SR-1951] 3 segmentation faults after migrating code to Swift 3 #44560

NachoSoto opened this issue Jun 30, 2016 · 26 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 SILGen Area → compiler: The SIL generation stage

Comments

@NachoSoto
Copy link
Contributor

Previous ID SR-1951
Radar rdar://problem/27718566
Original Reporter @NachoSoto
Type Bug
Status Resolved
Resolution Cannot Reproduce

Attachment: Download

Environment

Xcode 8.0 beta 1, 2, 3, and 4, and GM:

Xcode 8.0 beta (8S128d)
Apple Swift version 3.0 (swiftlang-800.0.30 clang-800.0.24)
Target: x86_64-apple-macosx10.9

Xcode Version 8.0 beta 2 (8S162m)
Apple Swift version 3.0 (swiftlang-800.0.33.1 clang-800.0.31)
Target: x86_64-apple-macosx10.9

Xcode Version 8.0 beta 3 (8S174q)
Apple Swift version 3.0 (swiftlang-800.0.34.6 clang-800.0.33)
Target: x86_64-apple-macosx10.9

Xcode Version 8.0 beta 4 (8S188o)
Apple Swift version 3.0 (swiftlang-800.0.41.2 clang-800.0.36)
Target: x86_64-apple-macosx10.9

Xcode Version 8.0 (8A218a)
Apple Swift version 3.0 (swiftlang-800.0.46.2 clang-800.0.38)
Target: x86_64-apple-macosx10.9
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, SILGen
Assignee @slavapestov
Priority Medium

md5: f5182b809e24358511c8e911dd55764c

Issue Description:

Steps to reproduce:

Expected result:

  • Framework compiles, or at least, produces compile errors.

Actual result:

  • 3 segmentation faults (see attached image).
@NachoSoto
Copy link
Contributor Author

This is still an issue with beta 2:

Xcode Version 8.0 beta 2 (8S162m)
Apple Swift version 3.0 (swiftlang-800.0.33.1 clang-800.0.31)
Target: x86_64-apple-macosx10.9

@harlanhaskins
Copy link
Collaborator

Have you been able to reduce the scope of the crasher, and maybe make a self-contained reproducer?

@NachoSoto
Copy link
Contributor Author

Unfortunately no. The crash doesn't give me many clues about where the issue is exactly...
Luckily this library is not very big though.

@NachoSoto
Copy link
Contributor Author

This is still an issue on Xcode 8.0 beta 3 🙁 same 3 segmentation faults

@aschwaighofer
Copy link
Member

@NachoSoto
Copy link
Contributor Author

Thanks! I'll verify this in the next Xcode beta.

@NachoSoto
Copy link
Contributor Author

This is still not fixed in Xcode 8 beta 4, Swift version 3.0 (swiftlang-800.0.41.2 clang-800.0.36)...

0  swift                    0x00000001044c3e3d PrintStackTraceSignalHandler(void*) + 45
1  swift                    0x00000001044c3886 SignalHandler(int) + 470
2  libsystem_platform.dylib 0x00007fffa095552a _sigtramp + 26
3  libsystem_platform.dylib 0x00007fff5e4d7b60 _sigtramp + 3182962256
4  swift                    0x0000000101990560 swift::Lowering::SILGenFunction::prepareEpilog(swift::Type, bool, swift::CleanupLocation) + 240
5  swift                    0x00000001019b00a6 swift::Lowering::SILGenFunction::emitClosure(swift::AbstractClosureExpr*) + 246
6  swift                    0x0000000101936643 swift::Lowering::SILGenModule::emitClosure(swift::AbstractClosureExpr*) + 1091
7  swift                    0x00000001019552d6 (anonymous namespace)::SILGenApply::visitAbstractClosureExpr(swift::AbstractClosureExpr*) + 38
8  swift                    0x00000001019572f7 (anonymous namespace)::SILGenApply::visitApplyExpr(swift::ApplyExpr*) + 5271
9  swift                    0x0000000101945d01 prepareApplyExpr(swift::Lowering::SILGenFunction&, swift::Expr*) + 273
10 swift                    0x0000000101991f9b swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 107
11 swift                    0x000000010199d5a0 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 46704
12 swift                    0x00000001019a57b0 swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 592
13 swift                    0x00000001019f0a11 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 4129
14 swift                    0x000000010197501c swift::Lowering::SILGenFunction::emitClassConstructorInitializer(swift::ConstructorDecl*) + 3900
15 swift                    0x0000000101934a9f swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*) + 5807
16 swift                    0x00000001019f7916 (anonymous namespace)::SILGenType::emitType() + 998
17 swift                    0x00000001019f74be swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 30
18 swift                    0x000000010193d02b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 1499
19 swift                    0x000000010193edb8 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 1608
20 swift                    0x00000001017982df performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 18831
21 swift                    0x0000000101791679 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 18137
22 swift                    0x000000010174e4a0 main + 10240
23 libdyld.dylib            0x00007fff9fa085ad start + 1
24 libdyld.dylib            0x000000000000005b start + 1616870063
Stack dump:
0.  Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/LocalImageRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/RemoteImageRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/AsyncImageView.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Hashing.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/ErrorIgnoringRenderer.swift -primary-file /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Caching.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/ImageInflaterRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/EmptyRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/ContextRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/FallbackRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Extensions.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/CacheRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/AnyRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/ImageProcessingRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/MulticastedRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/Renderer.swift -target x86_64-apple-ios9.0 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk -I /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator -F /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator -F /Users/NachoSoto/Development/AsyncImageView/Carthage/Build/iOS -application-extension -enable-testing -g -import-underlying-module -module-cache-path /Users/NachoSoto/Library/Developer/Xcode/DerivedData/ModuleCache -D DEBUG -serialize-debugging-options -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/AsyncImageView-generated-files.hmap -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/AsyncImageView-own-target-headers.hmap -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/AsyncImageView-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/AsyncImageView-project-headers.hmap -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/UninstalledProducts/include -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/DerivedSources/x86_64 -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -DDEBUG=1 -Xcc -ivfsoverlay -Xcc /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/unextended-module-overlay.yaml -Xcc -working-directory/Users/NachoSoto/Development/AsyncImageView -emit-module-doc-path /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/Objects-normal/x86_64/Caching~partial.swiftdoc -Onone -module-name AsyncImageView -emit-module-path /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/Objects-normal/x86_64/Caching~partial.swiftmodule -serialize-diagnostics-path /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/Objects-normal/x86_64/Caching.dia -emit-dependencies-path /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/Objects-normal/x86_64/Caching.d -emit-reference-dependencies-path /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/Objects-normal/x86_64/Caching.swiftdeps -o /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/Objects-normal/x86_64/Caching.o 
1.  While silgen constructor initializer SIL function @_TFC14AsyncImageView13InMemoryCachecfT9cacheNameSS_GS0_xq__ for 'init' at /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Caching.swift:30:9
2.  While silgen closureexpr SIL function @_TFFC14AsyncImageView13InMemoryCachecFT9cacheNameSS_GS0_xq__U_FT_GCSo7NSCacheGCS_P33_357E68683E897D03A6332D6EB237D58E8CacheKeyQ__GCS_P33_357E68683E897D03A6332D6EB237D58E10CacheValueQ0___ for expression at [/Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Caching.swift:31:16 - line:36:3] RangeText="{
            let cache = NativeCacheType()
            cache.name = cacheName

            return cache
        }"

You can reproduce this by checking out the branch I mentioned.

@NachoSoto
Copy link
Contributor Author

I just want to mention that this is completely blocking my ability to even build my app with Swift 3 (this is just one of the libraries I made for it), 4 betas later, and therefore not allowing me to potentially find even more issues.

@NachoSoto
Copy link
Contributor Author

Also it looks like this is associated to a Radar, which is not publicly accessible. You might want to mark that as not-fixed too.

@aschwaighofer
Copy link
Member

The mentioned commit is not in beta 4.

If I remember correctly you should be able to work around this by removing the closure in InMemoryCache.init(cacheName🙂

Instead of:
public init(cacheName: String) {
self.cache = {
let cache = NativeCacheType()
cache.name = cacheName

return cache
}()
}

You could write:

public init(cacheName: String) {
cache = NativeCacheType()
cache.name = cacheName
}

@NachoSoto
Copy link
Contributor Author

I pushed the changes for beta-4 40 minutes ago. The commit hash is 57d7ec8.
Doing that fixes just one of the 3 segmentation faults:

@NachoSoto
Copy link
Contributor Author

These are the other 2 stack traces:

0  swift                    0x00000001086f9e3d PrintStackTraceSignalHandler(void*) + 45
1  swift                    0x00000001086f9886 SignalHandler(int) + 470
2  libsystem_platform.dylib 0x00007fffa095552a _sigtramp + 26
3  libsystem_platform.dylib 0x15fba13c62334ee3 _sigtramp + 3248355795
4  swift                    0x0000000105a96289 swift::irgen::IRGenFunction::emitTypeMetadataRef(swift::CanType) + 73
5  swift                    0x0000000105ad2568 swift::irgen::NecessaryBindings::save(swift::irgen::IRGenFunction&, swift::irgen::Address) const + 312
6  swift                    0x0000000105a82bac swift::irgen::emitFunctionPartialApplication(swift::irgen::IRGenFunction&, swift::SILFunction&, llvm::Value*, llvm::Value*, swift::irgen::Explosion&, llvm::ArrayRef<swift::SILParameterInfo>, llvm::ArrayRef<swift::Substitution>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::irgen::Explosion&) + 3020
7  swift                    0x0000000105b29907 swift::SILVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::ValueBase*) + 49367
8  swift                    0x0000000105b1adad swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 8541
9  swift                    0x0000000105a41220 swift::irgen::IRGenerator::emitLazyDefinitions() + 5152
10 swift                    0x0000000105b00c1b performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 1723
11 swift                    0x00000001059cf337 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 23015
12 swift                    0x00000001059c7679 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 18137
13 swift                    0x00000001059844a0 main + 10240
14 libdyld.dylib            0x00007fff9fa085ad start + 1
15 libdyld.dylib            0x000000000000005b start + 1616870063
Stack dump:
0.  Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/LocalImageRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/RemoteImageRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/AsyncImageView.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Hashing.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/ErrorIgnoringRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Caching.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/ImageInflaterRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/EmptyRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/ContextRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/FallbackRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Extensions.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/CacheRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/AnyRenderer.swift -primary-file /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/ImageProcessingRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/MulticastedRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/Renderer.swift -target x86_64-apple-ios9.0 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk -I /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator -F /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator -F /Users/NachoSoto/Development/AsyncImageView/Carthage/Build/iOS -application-extension -enable-testing -g -import-underlying-module -module-cache-path /Users/NachoSoto/Library/Developer/Xcode/DerivedData/ModuleCache -D DEBUG -serialize-debugging-options -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/AsyncImageView-generated-files.hmap -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/AsyncImageView-own-target-headers.hmap -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/AsyncImageView-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/AsyncImageView-project-headers.hmap -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/UninstalledProducts/include -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/DerivedSources/x86_64 -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -DDEBUG=1 -Xcc -ivfsoverlay -Xcc /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/unextended-module-overlay.yaml -Xcc -working-directory/Users/NachoSoto/Development/AsyncImageView -emit-module-doc-path /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/Objects-normal/x86_64/ImageProcessingRenderer~partial.swiftdoc -Onone -module-name AsyncImageView -emit-module-path /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/Objects-normal/x86_64/ImageProcessingRenderer~partial.swiftmodule -serialize-diagnostics-path /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/Objects-normal/x86_64/ImageProcessingRenderer.dia -emit-dependencies-path /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/Objects-normal/x86_64/ImageProcessingRenderer.d -emit-reference-dependencies-path /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/Objects-normal/x86_64/ImageProcessingRenderer.swiftdeps -o /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/Objects-normal/x86_64/ImageProcessingRenderer.o 
1.  While emitting IR SIL function @_TTRGRx14AsyncImageView12RendererTyperXFo_oCSo7UIImageoCSo9CGContextdVSC6CGSizeoXFo_____XFdCb_dS1_dS2_dS3_dXFdCb_____

0  swift                    0x0000000106572e3d PrintStackTraceSignalHandler(void*) + 45
1  swift                    0x0000000106572886 SignalHandler(int) + 470
2  libsystem_platform.dylib 0x00007fffa095552a _sigtramp + 26
3  libsystem_platform.dylib 000000000000000000 _sigtramp + 1600826096
4  swift                    0x000000010386e652 llvm::Value* llvm::function_ref<llvm::Value* (unsigned int)>::callback_fn<swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*)::$_0>(long, unsigned int) + 530
5  swift                    0x000000010394c040 swift::irgen::emitImpliedWitnessTableRef(swift::irgen::IRGenFunction&, llvm::ArrayRef<swift::irgen::ProtocolEntry>, swift::ProtocolDecl*, llvm::function_ref<llvm::Value* (unsigned int)> const&) + 240
6  swift                    0x000000010386e427 swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*) + 247
7  swift                    0x0000000103948413 swift::SILWitnessVisitor<(anonymous namespace)::WitnessTableBuilder>::visitProtocolDecl(swift::ProtocolDecl*) + 5987
8  swift                    0x0000000103945f27 swift::irgen::IRGenModule::emitSILWitnessTable(swift::SILWitnessTable*) + 503
9  swift                    0x00000001038b867d swift::irgen::IRGenerator::emitGlobalTopLevel() + 2013
10 swift                    0x0000000103979a4b performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 1259
11 swift                    0x0000000103848337 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 23015
12 swift                    0x0000000103840679 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 18137
13 swift                    0x00000001037fd4a0 main + 10240
14 libdyld.dylib            0x00007fff9fa085ad start + 1
Stack dump:
0.  Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/LocalImageRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/RemoteImageRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/AsyncImageView.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Hashing.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/ErrorIgnoringRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Caching.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/ImageInflaterRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/EmptyRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/ContextRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/FallbackRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Extensions.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/CacheRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/AnyRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/ImageProcessingRenderer.swift -primary-file /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/MulticastedRenderer.swift /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Renderers/Renderer.swift -target x86_64-apple-ios9.0 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk -I /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator -F /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator -F /Users/NachoSoto/Development/AsyncImageView/Carthage/Build/iOS -application-extension -enable-testing -g -import-underlying-module -module-cache-path /Users/NachoSoto/Library/Developer/Xcode/DerivedData/ModuleCache -D DEBUG -serialize-debugging-options -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/AsyncImageView-generated-files.hmap -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/AsyncImageView-own-target-headers.hmap -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/AsyncImageView-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/AsyncImageView-project-headers.hmap -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/UninstalledProducts/include -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/DerivedSources/x86_64 -Xcc -I/Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -DDEBUG=1 -Xcc -ivfsoverlay -Xcc /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/unextended-module-overlay.yaml -Xcc -working-directory/Users/NachoSoto/Development/AsyncImageView -emit-module-doc-path /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/Objects-normal/x86_64/MulticastedRenderer~partial.swiftdoc -Onone -module-name AsyncImageView -emit-module-path /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/Objects-normal/x86_64/MulticastedRenderer~partial.swiftmodule -serialize-diagnostics-path /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/Objects-normal/x86_64/MulticastedRenderer.dia -emit-dependencies-path /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/Objects-normal/x86_64/MulticastedRenderer.d -emit-reference-dependencies-path /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/Objects-normal/x86_64/MulticastedRenderer.swiftdeps -o /Users/NachoSoto/Library/Developer/Xcode/DerivedData/Build/Intermediates/AsyncImageView.build/Debug-iphonesimulator/AsyncImageView-iOS.build/Objects-normal/x86_64/MulticastedRenderer.o 

@aschwaighofer
Copy link
Member

Reproduced on the swift-3.0-preview-4-branch:

AsyncImageView/Renderers/ImageProcessingRenderer.swift

Assertion failed: (!archetype->isPrimary() && "type metadata for primary archetype was not bound in context"), function emitArchetypeTypeMetadataRef, file /Users/arnold/Desktop/LLVMCompilerGitHub2/swift/lib/IRGen/GenArchetype.cpp, line 62.
0 swift 0x0000000108b7ec4b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1 swift 0x0000000108b7de96 llvm::sys::RunSignalHandlers() + 70
2 swift 0x0000000108b7f39f SignalHandler(int) + 383
3 libsystem_platform.dylib 0x00007fffdab8a01a _sigtramp + 26
4 swift 0x000000010976f611 cmark_strbuf__initbuf + 75136
5 swift 0x0000000108b7f0ee abort + 14
6 swift 0x0000000108b7f0d1 __assert_rtn + 81
7 swift 0x0000000105f072a6 swift::irgen::emitArchetypeTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>) + 182
8 swift 0x0000000105fb2b48 llvm::Value* swift::CanTypeVisitor<(anonymous namespace)::EmitTypeMetadataRef, llvm::Value*>::visit<>(swift::CanType) + 776
9 swift 0x0000000105f9da10 swift::irgen::IRGenFunction::emitTypeMetadataRef(swift::CanType) + 96
10 swift 0x0000000105fd4a47 swift::irgen::emitInitOfGenericRequirementsBuffer(swift::irgen::IRGenFunction&, llvm::ArrayRef<swift::irgen::GenericRequirement>, swift::irgen::Address, llvm::function_ref<llvm::Value* (swift::irgen::GenericRequirement)>) + 455
11 swift 0x0000000105fd4873 swift::irgen::NecessaryBindings::save(swift::irgen::IRGenFunction&, swift::irgen::Address) const + 83
12 swift 0x0000000105f87a12 swift::irgen::emitFunctionPartialApplication(swift::irgen::IRGenFunction&, swift::SILFunction&, llvm::Value*, llvm::Value*, swift::irgen::Explosion&, llvm::ArrayRef<swift::SILParameterInfo>, llvm::ArrayRef<swift::Substitution>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::irgen::Explosion&) + 3714
13 swift 0x000000010603ed52 swift::SILVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::ValueBase*) + 49794
14 swift 0x000000010602df39 (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 8553
15 swift 0x000000010602b98a swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 1242
16 swift 0x0000000105f439cb swift::irgen::IRGenerator::emitLazyDefinitions() + 715
17 swift 0x000000010600c44c performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 1260
18 swift 0x000000010600c855 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, unsigned int) + 69
19 swift 0x0000000105ef111f performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 16079
20 swift 0x0000000105eebfaf swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2895
21 swift 0x0000000105eaeb10 main + 2448
22 libdyld.dylib 0x00007fffda97e255 start + 1
Stack dump

AsyncImageView/Renderers/MulticastedRenderer.swift:

no relation found that declares conformance to target
UNREACHABLE executed at /Users/arnold/Desktop/LLVMCompilerGitHub2/swift/lib/IRGen/GenArchetype.cpp:140!
0 swift 0x00000001073a0c4b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1 swift 0x000000010739fe96 llvm::sys::RunSignalHandlers() + 70
2 swift 0x00000001073a139f SignalHandler(int) + 383
3 libsystem_platform.dylib 0x00007fffdab8a01a _sigtramp + 26
4 swift 0x0000000107f91611 cmark_strbuf__initbuf + 75136
5 swift 0x00000001073a10ee abort + 14
6 swift 0x0000000107340ab7 llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 471
7 swift 0x000000010472ba30 llvm::Value* llvm::function_ref<llvm::Value* (unsigned int)>::callback_fn<swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*)::$_0>(long, unsigned int) + 368
8 swift 0x00000001047f6fc1 swift::irgen::emitImpliedWitnessTableRef(swift::irgen::IRGenFunction&, llvm::ArrayRef<swift::irgen::ProtocolEntry>, swift::ProtocolDecl*, llvm::function_ref<llvm::Value* (unsigned int)> const&) + 273
9 swift 0x0000000104729444 swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*) + 164
10 swift 0x00000001047fc18c swift::SILWitnessVisitor<(anonymous namespace)::WitnessTableBuilder>::visitProtocolDecl(swift::ProtocolDecl*) + 5100
11 swift 0x00000001047f3a5c swift::irgen::IRGenModule::emitSILWitnessTable(swift::SILWitnessTable*) + 396
12 swift 0x0000000104765167 swift::irgen::IRGenerator::emitGlobalTopLevel() + 791
13 swift 0x000000010482e34e performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 1006
14 swift 0x000000010482e855 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, unsigned int) + 69
15 swift 0x000000010471311f performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 16079
16 swift 0x000000010470dfaf swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2895
17 swift 0x00000001046d0b10 main + 2448
18 libdyld.dylib 0x00007fffda97e255 start + 1

@NachoSoto
Copy link
Contributor Author

Yay

@aschwaighofer
Copy link
Member

The bug in ImageProcessingRenderer can be worked around by changing renderImageWithData to:


    public func renderImageWithData(_ data: Renderer.Data) -> SignalProducer<UIImage, Renderer.Error> {
        let deferredSize = { return data.size }
        return self.renderer.renderImageWithData(data)
            .observe(on: self.schedulerCreator())
            .map { $0.image }
            .map { [scale = self.scale, opaque = self.opaque, block = self.renderingBlock] image in
                image.processImageWithBitmapContext(
                    withSize: deferredSize(),
                    scale: scale,
                    opaque: opaque,
                    renderingBlock: block
                )
            }
    }

@aschwaighofer
Copy link
Member

The bug in MulticastedRenderer can be worked around by reordering the type parameters 'Renderer' and 'Data'.

diff --git a/AsyncImageView/Renderers/MulticastedRenderer.swift b/AsyncImageView/Renderers/MulticastedRenderer.swift
index 3d6f406..1493090 100644
--- a/AsyncImageView/Renderers/MulticastedRenderer.swift
+++ b/AsyncImageView/Renderers/MulticastedRenderer.swift
@@ -17,8 +17,8 @@ private typealias ImageProperty = Property<ImageResult?>
 /// `RendererType` decorator which guarantees that images for a given `RenderDataType`
 /// are only rendered once, and multicasted to every observer.
 public final class MulticastedRenderer<
-       Data: RenderDataType,
-       Renderer: RendererType
+    Renderer: RendererType,
+    Data: RenderDataType
        where
        Renderer.Data == Data,
        Renderer.Error == NoError
@@ -80,7 +80,7 @@ public final class MulticastedRenderer<
 
 extension RendererType where Error == NoError {
        /// Multicasts the results of this `RendererType`.
-       public func multicasted() -> MulticastedRenderer<Self.Data, Self> {
+       public func multicasted() -> MulticastedRenderer<Self, Self.Data> {
                return MulticastedRenderer(renderer: self)
        }
 }

@aschwaighofer
Copy link
Member

A fixe for the MulticastedRenderer crash is at apple/swift#4208

@aschwaighofer
Copy link
Member

MulticastedRenderer needed another similar fix: apple/swift#4330

@NachoSoto
Copy link
Contributor Author

This is still not fixed in Xcode 8 GM, which is extremely disappointing. I reported this in beta 1, and the final version of Xcode has been released without a fix, which means that I can't release an update for my app in time.

I honestly don't know why I even wasted my time to report this.

@NachoSoto
Copy link
Contributor Author

I pushed the updated code to the branch (see description), so you can reproduce this yourself.

@aschwaighofer
Copy link
Member

I am sorry. Unfortunately, the mentioned changes did not make it into Xcode 8. We don't have a fix for the third issue yet.

Do the workarounds I posted above (Aug 5 and 8) not work for you? I tested them with Xcode beta 4 and they seemed to work for me.

@NachoSoto
Copy link
Contributor Author

Those workarounds fix 2 segfaults, but there's still a third one in Caching.swift:

0  swift                    0x0000000106928b6d PrintStackTraceSignalHandler(void*) + 45
1  swift                    0x00000001069285b6 SignalHandler(int) + 470
2  libsystem_platform.dylib 0x00007fffc78adbba _sigtramp + 26
3  libsystem_platform.dylib 0x00007fff00000003 _sigtramp + 947201123
4  swift                    0x00000001045533d9 swift::constraints::ConstraintSystem::solveRec(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 57
5  swift                    0x000000010455c6b4 swift::constraints::ConstraintSystem::solveSimplified(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 23892
6  swift                    0x0000000104553650 swift::constraints::ConstraintSystem::solveRec(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 688
7  swift                    0x0000000104552f92 swift::constraints::ConstraintSystem::solve(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 66
8  swift                    0x0000000104552ec5 swift::constraints::ConstraintSystem::solveSingle(swift::FreeTypeVariableBinding) + 69
9  swift                    0x00000001045a4d34 swift::TypeChecker::typesSatisfyConstraint(swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::DeclContext*) + 132
10 swift                    0x00000001045a4dce swift::TypeChecker::typeCheckCheckedCast(swift::Type, swift::Type, swift::DeclContext*, swift::SourceLoc, swift::SourceRange, swift::SourceRange, std::__1::function<bool (swift::Type)>, bool) + 94
11 swift                    0x00000001044fe3e0 swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) + 20032
12 swift                    0x000000010452382f swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::Expr*) + 4367
13 swift                    0x000000010459ce75 swift::TypeChecker::solveForExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem&, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 1157
14 swift                    0x000000010459f59f swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 703
15 swift                    0x0000000104621bb2 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 6114
16 swift                    0x0000000104620516 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 326
17 swift                    0x000000010461f5ad swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 365
18 swift                    0x0000000104623cfc swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 188
19 swift                    0x00000001045d864a swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 6714
20 swift                    0x000000010428daab swift::CompilerInstance::performSema() + 5643
21 swift                    0x0000000103d3a00d performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 2765
22 swift                    0x0000000103d37265 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 17029
23 swift                    0x0000000103cf482d main + 8685
24 libdyld.dylib            0x00007fffc76a1255 start + 1
25 libdyld.dylib            0x000000000000005b start + 949349895

1.  While type-checking 'valueForKey' at /Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Caching.swift:35:9
2.  While type-checking expression at [/Users/NachoSoto/Development/AsyncImageView/AsyncImageView/Caching.swift:37:10 - line:37:54] RangeText="cache.object(forKey: CacheKey(value: key))?.v"

@aschwaighofer
Copy link
Member

The bug in Caching.swift is a new bug in the the type checker it should have noted the ambiguity error you get if you change valueForKey to:

    public func valueForKey(_ key: K) -> V? {
        let o = cache.object(forKey: CacheKey(value: key))
        if let v = o {
          return v.value
        }
        return nil
        //return cache.object(forKey: CacheKey(value: key))?.myValue
    }

/Users/arnold/Desktop/AsyncImageView_GM/AsyncImageView/Caching.swift:38:18: error: ambiguous reference to member 'value(forKey🙂'
return v.value
^
Foundation.NSObject:4:15: note: found this candidate
open func value(forKey key: String) -> Any?
^
Foundation.NSObject:18:15: note: found this candidate
open func value(forKeyPath keyPath: String) -> Any?
^
Foundation.NSObject:32:15: note: found this candidate
open func value(forUndefinedKey key: String) -> Any?

You can fix the ambiguity by changing the name of the CacheValue.value property (it was causing some ambiguity with NSObject.value(for...) to the following:

    public func valueForKey(_ key: K) -> V? {
        return cache.object(forKey: CacheKey(value: key))?.myValue
    }

private final class CacheValue<V>: NSObject {
    public let myValue: V

    init(value: V) {
        self.myValue = value
    }
}

@aschwaighofer
Copy link
Member

Filed https://bugs.swift.org/browse/SR-2592 for the type checker issue.

@slavapestov
Copy link
Member

Hey @NachoSoto, this bug is all fixed now right?

@NachoSoto
Copy link
Contributor Author

I never disabled the workarounds in my code so I'm not 100% sure :/ But feel free to close this.

@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 SILGen Area → compiler: The SIL generation stage
Projects
None yet
Development

No branches or pull requests

5 participants