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-10918] Segfault when using didSet with a property wrapper #53309

Closed
mdiep opened this issue Jun 12, 2019 · 4 comments
Closed

[SR-10918] Segfault when using didSet with a property wrapper #53309

mdiep opened this issue Jun 12, 2019 · 4 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 property wrappers Feature: property wrappers

Comments

@mdiep
Copy link
Contributor

mdiep commented Jun 12, 2019

Previous ID SR-10918
Radar rdar://problem/51669930
Original Reporter @mdiep
Type Bug
Status Closed
Resolution Done
Environment

Xcode 11 beta 1
Apple Swift version 5.1 (swiftlang-1100.0.38.29 clang-1100.0.20.14)
Target: x86_64-apple-darwin19.0.0

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, CompilerCrash, PropertyWrappers
Assignee @mdiep
Priority Medium

md5: 9ec450257a4dcea33a27acfcc074b8c2

is duplicated by:

Issue Description:

I'm seeing a segfault with this:

struct ContentView: View {
    @State var text: String = "" {
        didSet {
            print("Next: \(text)")
        }
    }

    var body: some View {
        Text("Foo")
    }
}

Remove the didSet and it compiles.

1.  While emitting property descriptor for 'text' (at /Users/mdiep/Repositories/mdiep/Zest/App/Source/ContentView.swift:18:16)
0  swift                    0x000000010845e8a3 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x000000010845e076 SignalHandler(int) + 358
2  libsystem_platform.dylib 0x00007fff642ffb1d _sigtramp + 29
3  libsystem_platform.dylib 0x00007fd3ac4b33e0 _sigtramp + 1209743584
4  swift                    0x0000000104567ac2 swift::Lowering::SILGenFunction::emitLValue(swift::Expr*, swift::Lowering::SGFAccessKind, swift::Lowering::LValueOptions) + 34
5  swift                    0x00000001044c8211 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 1425
6  swift                    0x00000001044d9915 (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::SmallVectorImpl<(anonymous namespace)::DelayedArgument>&, llvm::Optional<swift::ForeignErrorConvention> const&, swift::ImportAsMemberStatus) && + 1061
7  swift                    0x00000001044d692b (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::CanTypeWrapper<swift::FunctionType>&, swift::Lowering::AbstractionPattern&, swift::CanTypeWrapper<swift::SILFunctionType>, llvm::Optional<swift::ForeignErrorConvention> const&, swift::ImportAsMemberStatus, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::Optional<swift::SILLocation>&, swift::CanTypeWrapper<swift::FunctionType>&) + 1451
8  swift                    0x00000001044d43e3 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 3059
9  swift                    0x00000001044e6f2e swift::Lowering::SILGenFunction::emitSetAccessor(swift::SILLocation, swift::SILDeclRef, swift::SubstitutionMap, swift::Lowering::ArgumentSource&&, bool, bool, swift::Lowering::PreparedArguments&&, swift::Lowering::ArgumentSource&&, bool) + 1806
10 swift                    0x00000001045625f9 (anonymous namespace)::GetterSetterComponent::set(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ArgumentSource&&, swift::Lowering::ManagedValue) && + 649
11 swift                    0x000000010456598c swift::Lowering::SILGenFunction::emitAssignToLValue(swift::SILLocation, swift::Lowering::ArgumentSource&&, swift::Lowering::LValue&&) + 2556
12 swift                    0x00000001045714be swift::Lowering::SILGenFunction::emitAssignToLValue(swift::SILLocation, swift::Lowering::RValue&&, swift::Lowering::LValue&&) + 142
13 swift                    0x0000000104546ad2 getOrCreateKeyPathSetter(swift::Lowering::SILGenModule&, swift::SILLocation, swift::AbstractStorageDecl*, swift::SubstitutionMap, swift::GenericEnvironment*, swift::ResilienceExpansion, llvm::ArrayRef<std::__1::pair<swift::CanType, swift::SILType> >, swift::CanType, swift::CanType) + 5490
14 swift                    0x000000010454002d swift::Lowering::SILGenModule::emitKeyPathComponentForDecl(swift::SILLocation, swift::GenericEnvironment*, swift::ResilienceExpansion, unsigned int&, bool&, swift::SubstitutionMap, swift::AbstractStorageDecl*, llvm::ArrayRef<swift::ProtocolConformanceRef>, swift::CanType, bool) + 4237
15 swift                    0x00000001044c0918 swift::Lowering::SILGenModule::tryEmitPropertyDescriptor(swift::AbstractStorageDecl*) + 1272
16 swift                    0x00000001045ab1a6 (anonymous namespace)::SILGenType::emitType() + 2230
17 swift                    0x00000001044c320d swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 77
18 swift                    0x00000001044c2456 swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) + 1238
19 swift                    0x00000001044c3edc swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*) + 1244
20 swift                    0x00000001040d0d75 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 28757
21 swift                    0x00000001040c6424 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6868
22 swift                    0x00000001040556b3 main + 1219
23 libdyld.dylib            0x00007fff640ff7a9 start + 1
error: Segmentation fault: 11
@jckarter
Copy link
Member

This seems like something we should disallow, at least in the short term; what does it even mean for `didSet` to be on a wrapper property?

@mattneub
Copy link

@jckarter I believe the proposal explicitly says that property observers on a wrapper property are okay. I quote:

"Property wrappers can be applied to properties at global, local, or type scope. Those properties can have observing accessors (willSet/didSet), but not explicitly-written getters or setters."

https://github.com/DougGregor/swift-evolution/blob/property-wrappers/proposals/0258-property-wrappers.md

@jckarter
Copy link
Member

You're right. I think Doug's fixed this already. Does it still crash in recent seeds for you?

@mattneub
Copy link

@jckarter No, it looks okay. I can segfault with property wrappers but that's not how I do it. 🙂

@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 property wrappers Feature: property wrappers
Projects
None yet
Development

No branches or pull requests

4 participants