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-14954] [Segment Fault] [Demo Provided] Clang failed to build a Swift subclass of a Obj-C class when using NSDictionary with block as it's generic parameter #57296

Open
swift-ci opened this issue Jul 22, 2021 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code completion Area → source tooling: code completion compiler The Swift compiler in itself source tooling Area: IDE support, SourceKit, and other source tooling

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-14954
Radar rdar://problem/81019909
Original Reporter shengyang (JIRA User)
Type Bug

Attachment: Download

Environment

I was using Xcode 13 beta 3 to create this demo. However Xcode 12.5.1 was tested, and failed as expected.

Additional Detail from JIRA
Votes 0
Component/s CodeCompletion, Compiler
Labels Bug
Assignee None
Priority Medium

md5: b084634c55c05bec98b88d99f47588ec

Issue Description:

Please check out this demo:
https://github.com/shengyang998/SwiftCompilationAndRuntimeCrash

It will be failed to build.
Here is the build log:

1.  Apple Swift version 5.5 (swiftlang-1300.0.24.13 clang-1300.0.25.10)
2.  
3.  While evaluating request IRGenRequest(IR Generation for file "/Users/soleilyu/Code/self/t/SwiftCompilationAndRuntimeCrash/SwiftCompilationAndRuntimeCrash/SubClass.swift")
4.  While emitting IR SIL function "@$s31SwiftCompilationAndRuntimeCrash8SubClassCACycfc".
 for 'init()' (at /Users/soleilyu/Code/self/t/SwiftCompilationAndRuntimeCrash/SwiftCompilationAndRuntimeCrash/SubClass.swift:13:14)
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x000000010f76bfc7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-frontend           0x000000010f76af58 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x000000010f76c5d6 SignalHandler(int) + 278
3  libsystem_platform.dylib 0x00007fff20436d7d _sigtramp + 29
4  libsystem_platform.dylib 0x00007fb500000002 _sigtramp + 18446743755340681890
5  swift-frontend           0x000000010cf1df04 (anonymous namespace)::X86_64ABIInfo::computeInfo(clang::CodeGen::CGFunctionInfo&) const + 2692
6  swift-frontend           0x000000010cb2b634 clang::CodeGen::CodeGenTypes::arrangeLLVMFunctionInfo(clang::CanQual<clang::Type>, bool, bool, llvm::ArrayRef<clang::CanQual<clang::Type> >, clang::FunctionType::ExtInfo, llvm::ArrayRef<clang::FunctionType::ExtParameterInfo>, clang::CodeGen::RequiredArgs) + 2804
7  swift-frontend           0x000000010ac0ab72 swift::irgen::Signature::getUncached(swift::irgen::IRGenModule&, swift::CanTypeWrapper<swift::SILFunctionType>, bool) + 1458
8  swift-frontend           0x000000010ad270cc swift::irgen::getObjCMethodCallee(swift::irgen::IRGenFunction&, swift::irgen::ObjCMethod const&, llvm::Value*, swift::irgen::CalleeInfo&&) + 172
9  swift-frontend           0x000000010ade466a (anonymous namespace)::IRGenSILFunction::visitFullApplySite(swift::FullApplySite) + 2890
10 swift-frontend           0x000000010adc467f swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 10335
11 swift-frontend           0x000000010ac70f77 swift::irgen::IRGenerator::emitGlobalTopLevel(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) + 1607
12 swift-frontend           0x000000010ad91afa swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 8938
13 swift-frontend           0x000000010adc1aec swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 204
14 swift-frontend           0x000000010ad9c87c llvm::Expected<swift::IRGenRequest::OutputType> swift::Evaluator::getResultUncached<swift::IRGenRequest>(swift::IRGenRequest const&) + 876
15 swift-frontend           0x000000010ad9640c swift::performIRGeneration(swift::FileUnit*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::GlobalVariable**) + 348
16 swift-frontend           0x000000010a8b4e99 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 2841
17 swift-frontend           0x000000010a8a6826 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 13494
18 swift-frontend           0x000000010a7e8588 main + 1032
19 libdyld.dylib            0x00007fff2040cf5d start + 1
error: Segmentation fault: 11 (in target 'SwiftCompilationAndRuntimeCrash' from project 'SwiftCompilationAndRuntimeCrash')

If you try to override the property `handlers`, you will find an error occurred in the autocompleted code.

It says:

Property 'handlers' with type '[String : (BaseClass?, Any?, BlockFromThirdParty?) -> Void]?' (aka 'Optional<Dictionary<String, (Optional<BaseClass>, Optional<Any>, Optional<(Any) -> ()>) -> ()>>') cannot override a property with type '[String : @convention(block) (BaseClass?, Any?, BlockFromThirdParty?) -> Void]?' (aka 'Optional<Dictionary<String, @convention(block) (Optional<BaseClass>, Optional<Any>, Optional<(Any) -> ()>) -> ()>>')
@typesanitizer
Copy link

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the source tooling Area: IDE support, SourceKit, and other source tooling label Feb 6, 2023
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. code completion Area → source tooling: code completion compiler The Swift compiler in itself source tooling Area: IDE support, SourceKit, and other source tooling
Projects
None yet
Development

No branches or pull requests

3 participants