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-11890] Property Wrapper Abort trap: 6 #54306

Closed
swift-ci opened this issue Dec 3, 2019 · 5 comments
Closed

[SR-11890] Property Wrapper Abort trap: 6 #54306

swift-ci opened this issue Dec 3, 2019 · 5 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Dec 3, 2019

Previous ID SR-11890
Radar rdar://problem/57711764
Original Reporter linqingmo (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 11.2.1

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug
Assignee linqingmo (JIRA)
Priority Medium

md5: 657ed4f1ee3a3366a97d00bd24e3144e

Issue Description:

@propertyWrapper
struct Wrapper<Value> {
    var wrappedValue: Value
    
    init(wrappedValue: Value) {
        self.wrappedValue = wrappedValue
    }
}


class T<Value> {
    @Wrapper var t: Value?
    
    func update(t: Value?) {
        self.t = t
    }
}


class T1: T<String> {
    func test() {
        t = "" // compile error
        update(t: "") // OK
    }
}


1.  While emitting SIL for 'test()' (at /Users/harry/dev/ios/new_mengo/testpr/testpr/main.swift:29:5)
2.  While silgen emitFunction SIL function "@$s6testpr2T1C4testyyF".
 for 'test()' (at /Users/harry/dev/ios/new_mengo/testpr/testpr/main.swift:29:5)
0  swift                    0x0000000104f54a13 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x0000000104f541e6 SignalHandler(int) + 358
2  libsystem_platform.dylib 0x00007fff6b144b1d _sigtramp + 29
3  libsystem_malloc.dylib   0x00007fff6b104071 szone_size + 45
4  libsystem_c.dylib        0x00007fff6b01aa1c abort + 120
5  libsystem_malloc.dylib   0x00007fff6b10ad20 turn_on_stack_logging + 0
6  libsystem_malloc.dylib   0x00007fff6b10aade malloc_report + 151
7  swift                    0x0000000101517ee3 llvm::DenseMap<swift::Lowering::TypeConverter::CachingTypeKey, swift::Lowering::TypeLowering const*, llvm::DenseMapInfo<swift::Lowering::TypeConverter::CachingTypeKey>, llvm::detail::DenseMapPair<swift::Lowering::TypeConverter::CachingTypeKey, swift::Lowering::TypeLowering const*> >::grow(unsigned int) + 627
8  swift                    0x0000000101517c57 llvm::detail::DenseMapPair<swift::Lowering::TypeConverter::CachingTypeKey, swift::Lowering::TypeLowering const*>* llvm::DenseMapBase<llvm::DenseMap<swift::Lowering::TypeConverter::CachingTypeKey, swift::Lowering::TypeLowering const*, llvm::DenseMapInfo<swift::Lowering::TypeConverter::CachingTypeKey>, llvm::detail::DenseMapPair<swift::Lowering::TypeConverter::CachingTypeKey, swift::Lowering::TypeLowering const*> >, swift::Lowering::TypeConverter::CachingTypeKey, swift::Lowering::TypeLowering const*, llvm::DenseMapInfo<swift::Lowering::TypeConverter::CachingTypeKey>, llvm::detail::DenseMapPair<swift::Lowering::TypeConverter::CachingTypeKey, swift::Lowering::TypeLowering const*> >::InsertIntoBucketImpl<swift::Lowering::TypeConverter::CachingTypeKey>(swift::Lowering::TypeConverter::CachingTypeKey const&, swift::Lowering::TypeConverter::CachingTypeKey const&, llvm::detail::DenseMapPair<swift::Lowering::TypeConverter::CachingTypeKey, swift::Lowering::TypeLowering const*>*) + 103
9  swift                    0x0000000101517bb1 swift::Lowering::TypeConverter::getTypeLoweringForLoweredType(swift::Lowering::TypeConverter::TypeKey, swift::ResilienceExpansion) + 513
10 swift                    0x0000000100ffdbab swift::Lowering::SILGenFunction::emitManagedRValueWithCleanup(swift::SILValue) + 155
11 swift                    0x000000010103b023 (anonymous namespace)::GetterSetterComponent::set(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ArgumentSource&&, swift::Lowering::ManagedValue) && + 3507
12 swift                    0x000000010103d9cc swift::Lowering::SILGenFunction::emitAssignToLValue(swift::SILLocation, swift::Lowering::ArgumentSource&&, swift::Lowering::LValue&&) + 2556
13 swift                    0x000000010100604d swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 32589
14 swift                    0x0000000101013f6f swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 799
15 swift                    0x0000000101073cf3 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 3139
16 swift                    0x0000000101029b5a swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 426
17 swift                    0x0000000100f8ed24 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 980
18 swift                    0x000000010108362b (anonymous namespace)::SILGenType::emitType() + 523
19 swift                    0x0000000100f9a5bd swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 77
20 swift                    0x0000000100f99806 swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) + 1238
21 swift                    0x0000000100f9b266 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*) + 1238
22 swift                    0x0000000100b9eda4 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 28340
23 swift                    0x0000000100b946e4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6820
24 swift                    0x0000000100b21be3 main + 1219
25 libdyld.dylib            0x00007fff6af432e5 start + 1
error: Abort trap: 6 (in target 'testpr' from project 'testpr')
@theblixguy
Copy link
Collaborator

No longer crashes on master

@beccadax
Copy link
Contributor

beccadax commented Dec 6, 2019

@swift-ci create

@swift-ci
Copy link
Collaborator Author

Comment by Maxim Krouk (JIRA)

I get the same error when implementing initializers with default parameters, which contain `wrappedValue` as a first argument and when this value is set in declaration by assignment sign.

@propertyWrapper
class Abort {
    var wrappedValue: Int
    var anotherValue: Int
    
    // Doesn't matter if wrappedValue is defaulted or not
    init(wrappedValue: Int = 1, anotherValue: Int = 0) { 
        self.wrappedValue = wrappedValue
        self.anotherValue = anotherValue
    }
}
 
struct Example
{     
    /// ✅ Works fine   
    @Abort(anotherValue: 1) var fine1 = 1

    /// ✅ Works fine
    @Abort(wrappedValue: 2) var fine2

    /// ✅ Works fine
    @Abort(wrappedValue: 3, anotherValue: 0) var fine3

    /// ❌ Causes `Abort trap: 6`
    @Abort() var not_fine = -1
}

My logs

1.  While emitting IR SIL function "@$s21PropertyWrapprs_tries7ExampleVACycfC".
 for 'init()' (at /Users/maximkrouk/Develop/Swift/Playgrounds/PropertyWrapprs-tries/PropertyWrapprs-tries/Wrappers/Test.swift:22:8)
0  swift                    0x0000000113e59a63 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x0000000113e59236 SignalHandler(int) + 358
2  libsystem_platform.dylib 0x00007fff686a742d _sigtramp + 29
3  libsystem_platform.dylib 0x00007fe280225778 _sigtramp + 397927272
4  libsystem_c.dylib        0x00007fff6857ca1c abort + 120
5  libsystem_malloc.dylib   0x00007fff68672647 has_default_zone0 + 0
6  libsystem_malloc.dylib   0x00007fff6867540e malloc_report + 151
7  libsystem_malloc.dylib   0x00007fff68666275 realloc + 312
8  swift                    0x000000010fb71a4d swift::irgen::SingleScalarTypeInfo<(anonymous namespace)::ClassTypeInfo, swift::irgen::ReferenceTypeInfo>::getSchema(swift::irgen::ExplosionSchema&) const + 157
9  swift                    0x000000010fce717e swift::SILInstructionVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::SILInstruction*) + 35646
10 swift                    0x000000010fcdbaca swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 9834
11 swift                    0x000000010fb86bd0 swift::irgen::IRGenerator::emitGlobalTopLevel() + 1712
12 swift                    0x000000010fcb8845 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**) + 1189
13 swift                    0x000000010faa3981 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 36673
14 swift                    0x000000010fa97234 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6820
15 swift                    0x000000010fa24733 main + 1219
16 libdyld.dylib            0x00007fff684ae7fd start + 1
error: Abort trap: 6 (in target 'PropertyWrapprs-tries' from project 'PropertyWrapprs-tries')

@hborla
Copy link
Member

hborla commented Jul 2, 2020

This is fixed in Swift 5.3. Could you please verify using Xcode 12 beta 1? Thank you!

@swift-ci
Copy link
Collaborator Author

swift-ci commented Jul 2, 2020

Comment by Maxim Krouk (JIRA)

Both examples compiled successfully 👍

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 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
Projects
None yet
Development

No branches or pull requests

4 participants