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-1659] Swift2.2.1 generics property crash #44268

Closed
swift-ci opened this issue Jun 2, 2016 · 2 comments
Closed

[SR-1659] Swift2.2.1 generics property crash #44268

swift-ci opened this issue Jun 2, 2016 · 2 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 run-time crash Bug → crash: Swift code crashed during execution runtime The Swift Runtime

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jun 2, 2016

Previous ID SR-1659
Radar None
Original Reporter akio0911 (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, RunTimeCrash, Runtime
Assignee @slavapestov
Priority Medium

md5: 7da633e4b605bca4b611dcb7a527e7ae

duplicates:

  • SR-815 Generic classes with default property initializers bug

Issue Description:

VewController has property that has a GenericsClass property, crash at runtime.

Example

import UIKit

protocol CellType {
    associatedtype Model
}

class DataSource<Item, Cell where Cell: CellType, Item == Cell.Model>: NSObject {
    var items: [Item] = []
    
    init(items: [Item], cellType: Cell.Type) {
        self.items = items
    }
}

struct A {
    var flag: Bool = false
}

class CellA: CellType {
    typealias Model = A
}

class MyViewController {
    var dataSource = DataSource(items: [A()], cellType: CellA.self)
}


@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        
        let vc = MyViewController()
        
        return true
    }
}

StackTrace

* thread #&#8203;1: tid = 0x3ec3, 0x00283d38 libswiftCore.dylib`swift_initClassMetadata_UniversalStrategy + 440, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x79de8)
  * frame #&#8203;0: 0x00283d38 libswiftCore.dylib`swift_initClassMetadata_UniversalStrategy + 440
    frame #&#8203;1: 0x00075bd8 SwiftCrashCode`___lldb_unnamed_function3$$SwiftCrashCode + 196
    frame #&#8203;2: 0x00285052 libswiftCore.dylib`(anonymous namespace)::GenericCacheEntry* llvm::function_ref<(anonymous namespace)::GenericCacheEntry* ()>::callback_fn<swift_getGenericMetadata::$_1>(long) + 18
    frame #&#8203;3: 0x00284f46 libswiftCore.dylib`swift::MetadataCache<(anonymous namespace)::GenericCacheEntry>::addMetadataEntry(swift::EntryRef<(anonymous namespace)::GenericCacheEntry>, ConcurrentList<swift::MetadataCache<(anonymous namespace)::GenericCacheEntry>::EntryPair>&, llvm::function_ref<(anonymous namespace)::GenericCacheEntry* ()>) + 80
    frame #&#8203;4: 0x00282efc libswiftCore.dylib`swift::MetadataCache<(anonymous namespace)::GenericCacheEntry>::findOrAdd(void const* const*, unsigned long, llvm::function_ref<(anonymous namespace)::GenericCacheEntry* ()>) + 308
    frame #&#8203;5: 0x00283054 libswiftCore.dylib`swift_getGenericMetadata3 + 68
    frame #&#8203;6: 0x00075ff4 SwiftCrashCode`type metadata accessor for DataSource<A, CellA> + 116 at AppDelegate.swift:0
    frame #&#8203;7: 0x0007524c SwiftCrashCode`MyViewController.init() -> MyViewController + 24 at AppDelegate.swift:32
    frame #&#8203;8: 0x000752f4 SwiftCrashCode`MyViewController.__allocating_init() -> MyViewController + 36 at AppDelegate.swift:0
    frame #&#8203;9: 0x000754fc SwiftCrashCode`AppDelegate.application(application=0x15e285f0, launchOptions=nil, self=0x15d29ff0) -> Bool + 52 at AppDelegate.swift:44
    frame #&#8203;10: 0x000756c0 SwiftCrashCode`@objc AppDelegate.application(UIApplication, didFinishLaunchingWithOptions : [NSObject : AnyObject]?) -> Bool + 260 at AppDelegate.swift:0
    frame #&#8203;11: 0x32224586 UIKit`-[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 274
    frame #&#8203;12: 0x32223eda UIKit`-[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1610
    frame #&#8203;13: 0x3221e56a UIKit`-[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 714
    frame #&#8203;14: 0x321ba6e8 UIKit`-[UIApplication handleEvent:withNewEvent:] + 3540
    frame #&#8203;15: 0x321b9850 UIKit`-[UIApplication sendEvent:] + 72
    frame #&#8203;16: 0x3221dca8 UIKit`_UIApplicationHandleEvent + 616
    frame #&#8203;17: 0x34826aec GraphicsServices`_PurpleEventCallback + 608
    frame #&#8203;18: 0x348266d6 GraphicsServices`PurpleEventCallback + 34
    frame #&#8203;19: 0x2f962a66 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
    frame #&#8203;20: 0x2f962a02 CoreFoundation`__CFRunLoopDoSource1 + 346
    frame #&#8203;21: 0x2f9611d6 CoreFoundation`__CFRunLoopRun + 1398
    frame #&#8203;22: 0x2f8cbebe CoreFoundation`CFRunLoopRunSpecific + 522
    frame #&#8203;23: 0x2f8cbca2 CoreFoundation`CFRunLoopRunInMode + 106
    frame #&#8203;24: 0x3221ced0 UIKit`-[UIApplication _run] + 760
    frame #&#8203;25: 0x3221814c UIKit`UIApplicationMain + 1136
    frame #&#8203;26: 0x000759c8 SwiftCrashCode`main + 172 at AppDelegate.swift:37
    frame #&#8203;27: 0x3a71fab6 libdyld.dylib`start + 2
@belkadan
Copy link
Contributor

belkadan commented Jun 2, 2016

@slavapestov, does this look familiar?

@slavapestov
Copy link
Member

Strange, does not reproduce in 2.2.1 on x86_64.

@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 run-time crash Bug → crash: Swift code crashed during execution runtime The Swift Runtime
Projects
None yet
Development

No branches or pull requests

4 participants