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-14305] Function property wrappers cause crashes when the wrapped value type differs from the generic #56664

Open
phausler opened this issue Mar 5, 2021 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@phausler
Copy link
Member

phausler commented Mar 5, 2021

Previous ID SR-14305
Radar rdar://problem/75118347
Original Reporter @phausler
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 8191b99435155e4047c577ad787bfb76

Issue Description:

@propertyWrapper
public struct Wrapper<T: AnyObject> {
public var wrappedValue: T?
public init(wrappedValue: T?) {
self.wrappedValue = wrappedValue
}
}

func test<T: AnyObject>(@wrapper context: T) { }

that crashes with the following:

```
1.  Swift version 5.4-dev (LLVM 3e5b885d17fe890, Swift 145196093320828)
2.  While evaluating request TypeCheckSourceFileRequest(source_file "./main.swift")
3.  While type-checking 'test(context:)' (at ./main.swift:38:1)
4.  While evaluating request InterfaceTypeRequest(propertyWrapperTaskAttached.(file).test(context:)@./main.swift:38:6)
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           0x00000001053a58d7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-frontend           0x00000001053a4848 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x00000001053a5f06 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff3265c4ad _sigtramp + 29
4  swift-frontend           0x0000000101845846 llvm::hash_code llvm::hashing::detail::hash_combine_recursive_helper::combine<std::__1::tuple<swift::CustomAttr*, swift::DeclContext*> >(unsigned long, char*, char*, std::__1::tuple<swift::CustomAttr*, swift::DeclContext*> const&) + 150
5  libsystem_c.dylib        0x00007fff32598f0b abort + 118
6  libsystem_c.dylib        0x00007fff325982e3 err + 0
7  swift-frontend           0x00000001058c9673 swift::ParamDecl::toFunctionParam(swift::Type) const (.cold.2) + 35
8  swift-frontend           0x00000001017c696a swift::ParamDecl::toFunctionParam(swift::Type) const + 522
9  swift-frontend           0x000000010195cc9e swift::ParameterList::getParams(llvm::SmallVectorImpl<swift::AnyFunctionType::Param>&) const + 62
10 swift-frontend           0x000000010150154c swift::InterfaceTypeRequest::evaluate(swift::Evaluator&, swift::ValueDecl*) const + 1420
11 swift-frontend           0x00000001017fad03 llvm::Expected<swift::InterfaceTypeRequest::OutputType> swift::Evaluator::getResultUncached<swift::InterfaceTypeRequest>(swift::InterfaceTypeRequest const&) + 403
12 swift-frontend           0x00000001017faaab llvm::Expected<swift::InterfaceTypeRequest::OutputType> swift::Evaluator::getResultCached<swift::InterfaceTypeRequest, (void*)0>(swift::InterfaceTypeRequest const&) + 107
13 swift-frontend           0x00000001017b70f5 swift::InterfaceTypeRequest::OutputType swift::evaluateOrDefault<swift::InterfaceTypeRequest>(swift::Evaluator&, swift::InterfaceTypeRequest, swift::InterfaceTypeRequest::OutputType) + 37
14 swift-frontend           0x00000001017acea0 swift::ValueDecl::getInterfaceType() const + 64
15 swift-frontend           0x000000010152dc96 (anonymous namespace)::DeclChecker::visitFuncDecl(swift::FuncDecl*) + 38
16 swift-frontend           0x0000000101526c84 (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 228
17 swift-frontend           0x0000000101526b8d swift::TypeChecker::typeCheckDecl(swift::Decl*) + 125
18 swift-frontend           0x00000001015d8988 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 184
19 swift-frontend           0x00000001015d991f llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 415
20 swift-frontend           0x00000001015d96d4 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 100
21 swift-frontend           0x00000001015d87f0 swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 32
22 swift-frontend           0x00000001008ed69a swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<void (swift::SourceFile&)>) + 90
23 swift-frontend           0x00000001008ed58a swift::CompilerInstance::performSema() + 74
24 swift-frontend           0x00000001007bea54 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4724
25 swift-frontend           0x0000000100758ba2 main + 514
26 dyld                     0x0000000118ceac71 start + 417
27 dyld                     000000000000000000 start + 18446744068998386992
28 swift-frontend           0x0000000100756000 __dso_handle + 0
<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)
@typesanitizer
Copy link

@swift-ci create

@hborla
Copy link
Member

hborla commented Mar 8, 2021

Not sure where exactly this got fixed, but on my branch for #36344 the compiler reports an error:

error: property type 'T' does not match 'wrappedValue' type 'T?'
func test<T: AnyObject>(@Wrapper context: T) { }
                                 ^~~~~~~~~~

@hborla
Copy link
Member

hborla commented Apr 27, 2021

This was still an issue for API property wrappers, which I've put up a PR to fix here: #37093

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants