Commit Graph

2 Commits

Author SHA1 Message Date
Mike Ash
591e3a371c [Test] Fix deinit_escape test.
When compiled with optimizations, the compiler saw that C() doesn't escape and stack promoted it, which breaks the check. Deliberately escape the object into a global array beforehand to ensure it has to be on the heap.

rdar://103369708
2022-12-15 13:22:28 -05:00
Mike Ash
108f7805e5 [Runtime] Fatal error if self escapes from deinit.
When deallocating a class instance, we check the retain count of the instance and error if it's greater than 1.

Self is allowed to be temporarily passed to other code from deinit, but there's no way to extend the lifetime of the object. Retaining it no longer extensd the lifetime. If self escapes from deinit, the result is a dangling pointer and eventual crash.

Instead of crashing randomly due to a dangling pointer, crash deliberately when destroying an object that has escaped.

rdar://93848484
2022-12-07 12:42:41 -05:00