# Lazy NSObject + deinit = trap

**URL:** <https://forums.swift.org/t/lazy-nsobject-deinit-trap/89879>\
**Category:** Using Swift\
**Tags:** lazy, deinit, nsobject\
**Created:** [October 3, 2026, 8:18pm UTC](https://forums.swift.org/t/lazy-nsobject-deinit-trap/89879 "2026-10-03T20:18:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tera](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tera/32/38201_2.png) [@tera](https://forums.swift.org/u/tera)\
**Post date:** [October 3, 2026, 8:18pm UTC](https://forums.swift.org/t/lazy-nsobject-deinit-trap/89879/1 "2026-10-03T20:18:07Z")

</div>

Found an interesting foot-gun (only traps with `NSObject` classes and only with Foundation on Apple platforms):

```swift
import Foundation

class C: NSObject {
    lazy var foo: Int = {
        // Thread 1: abort with payload or reason
        // Cannot form weak reference to instance (0x1007e24f0) of class C.
        // It is possible that this object was over-released, or is in the process of deallocation.
        weak var y: C? = self
        return 1
    }()
    deinit {
        _ = foo
    }
}

do { _ = C() }
print("ended")

```

The question is whether this should not trap. Or trap in all cases (including non NSObject and non Apple platforms).
