I've been debugging this EXC_BAD_ACCESS (SIGSEGV) crash for multiple days with no luck. Here is everything I know so far
The crash happens after iPhone's orientation is changed while a UIViewController is presented as form or page sheet.
Crash only happens on iPhone. The never crashes on iPad
The crash happens when any UIViewController is presented as a form or page sheet. If it is presented as any other modal style, the crash does not happen.
The presented UIViewController can be anything, including completely raw and empty UIViewController.
The crash does not happen if I do not add a leading constraint to the UITextField inside the UITableViewCell of a presenting view controller table view.
The leading constraint can be any constraint. This constraint never conflicts with anything and is never broken.
The Allocations Instrument in Xcode does not show any related views, controllers or objects deallocated.
Enabling Zombie Objects in the scheme settings changes nothing.
Enabling either Address Sanitizer or Thread Sanitizer completely removes the crash.
Crash report:
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libobjc.A.dylib 0x7ff80002d7c5 objc_msgSend + 5
1 QuartzCore 0x7ff80898b02c CA::Layer::layout_if_needed(CA::Transaction*) + 526
2 QuartzCore 0x7ff8089847af -[CALayer layoutIfNeeded] + 333
3 UIKitCore 0x10e5d1336 __86-[UIViewController window:willAnimateRotationToInterfaceOrientation:duration:newSize:]_block_invoke + 52
4 UIKitCore 0x10f4d43ca +[UIView _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 588
5 UIKitCore 0x10f4d476d +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:] + 25
6 UIKitCore 0x10e5d12cc -[UIViewController window:willAnimateRotationToInterfaceOrientation:duration:newSize:] + 339
7 UIKitCore 0x10e5d9a8a __104-[UIViewController(AdaptiveSizing_Internal) _window:viewWillTransitionToSize:withTransitionCoordinator:]_block_invoke.3577 + 54
8 UIKitCore 0x10e5e274a -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:] + 297
9 UIKitCore 0x10e5dec8f -[_UIViewControllerTransitionContext __runAlongsideAnimations] + 278
10 UIKitCore 0x10f4d43ca +[UIView _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 588
11 UIKitCore 0x10f4d476d +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:] + 25
12 UIKitCore 0x10e5fb9b4 __58-[_UIWindowRotationAnimationController animateTransition:]_block_invoke_2 + 280
13 UIKitCore 0x10f4d891f +[UIView _performBlockDelayingTriggeringResponderEvents:forScene:] + 209
14 UIKitCore 0x10e5fb732 __58-[_UIWindowRotationAnimationController animateTransition:]_block_invoke + 152
15 UIKitCore 0x10f4d58f5 +[UIView(UIViewAnimationWithBlocksPrivate) _modifyAnimationsWithPreferredFrameRateRange:updateReason:animations:] + 164
16 UIKitCore 0x10f4d43ca +[UIView _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 588
17 UIKitCore 0x10f4d476d +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:] + 25
18 UIKitCore 0x10e5fb5a8 -[_UIWindowRotationAnimationController animateTransition:] + 594
19 UIKitCore 0x10eeff7cb -[UIWindow _rotateToBounds:withAnimator:transitionContext:] + 640
20 UIKitCore 0x10ef02b73 -[UIWindow _rotateWindowToOrientation:updateStatusBar:duration:skipCallbacks:] + 2034
21 UIKitCore 0x10ef0313b -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 641
22 UIKitCore 0x10eefe779 -[UIWindow _internal_setRotatableViewOrientation:updateStatusBar:duration:force:] + 113
23 UIKitCore 0x10ef00d36 __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 214
24 UIKitCore 0x10ef009a5 -[UIWindow _updateToInterfaceOrientation:duration:force:] + 1558
25 UIKitCore 0x10e2dfb98 -[_UIScenefbsSceneBasedMetricsCalculator _updateMetricsOnWindows:animated:] + 1844
26 UIKitCore 0x10f1a2aca -[UIWindowScene _computeMetricsForWindows:animated:] + 89
27 UIKitCore 0x10f1a1eb2 __33-[UIWindowScene _computeMetrics:]_block_invoke + 130
28 UIKitCore 0x10f1a2021 -[UIWindowScene _computeMetricsAndForceDelegateCallback:withAction:] + 326
29 UIKitCore 0x10f1a1e2a -[UIWindowScene _computeMetrics:] + 75
30 UIKitCore 0x10f4d43ca +[UIView _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 588
31 UIKitCore 0x10f4d4684 +[UIView(UIViewAnimationWithBlocks) _animateWithDuration:delay:options:factory:animations:completion:] + 20
32 UIKitCore 0x10e822877 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:fromCurrentState:actions:completion:] + 625
33 UIKitCore 0x10e9702a3 _UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion + 257
34 UIKitCore 0x10e2e62f1 -[_UIWindowSceneGeometrySettingsDiffAction _updateSceneGeometryWithSettingObserverContext:windowScene:transitionContext:] + 700
35 UIKitCore 0x10e2e5f88 -[_UIWindowSceneGeometrySettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 1537
36 UIKitCore 0x10e0cf5ae __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.594 + 815
37 UIKitCore 0x10e0cdfc4 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 245
38 UIKitCore 0x10e0cf15b -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 255
39 UIKitCore 0x10e8557be -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 475
40 FrontBoardServices 0x7ff80549e4b4 -[FBSScene updater:didUpdateSettings:withDiff:transitionContext:completion:] + 521