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-10920] Crash in NSObject.__old_unswizzled_keyPathsForValuesAffectingValue(forKey:) #4002

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

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-10920
Radar None
Original Reporter djs-code (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

Swift 5
Xcode 10.2.1 (10E1001)
iPhone 8 (iOS 12.2)

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: 634bfce470d854cecc72a33e08d6f7bd

duplicates:

  • SR-6795 Swift 4 KVO swizzling is not thread-safe, causes crashes

Issue Description:

I recently stumbled upon the following crash running UI Tests for our app.

Fatal error: Should never be reached: file /BuildRoot/Library/Caches/com.apple.xbs/Sources/swiftlang_overlay_Foundation_Sim/swiftlang-1001.2.63.13/swift/stdlib/public/SDK/Foundation/NSObject.swift, line 46
Thread 1 Queue : TTConfigurationModelCoordinator (serial)
#​0  0x000000011849bba8 in specialized _assertionFailure(_:_:file:line:flags:) ()
#​1  0x0000000118295dd9 in _assertionFailure(_:_:file:line:flags:) ()
#​2  0x0000000118aa899a in @objc static NSObject.__old_unswizzled_keyPathsForValuesAffectingValue(forKey:) ()
#​3  0x0000000118aa9052 in static __KVOKeyPathBridgeMachinery.keyPathsForValuesAffectingValue(forKey:) ()
#​4  0x0000000118aa959d in @objc static __KVOKeyPathBridgeMachinery.keyPathsForValuesAffectingValue(forKey:) ()
#​5  0x000000010ff49fd0 in -[NSKeyValueUnnestedProperty _givenPropertiesBeingInitialized:getAffectingProperties:] ()
#​6  0x000000010ff49c17 in -[NSKeyValueUnnestedProperty _initWithContainerClass:key:propertiesBeingInitialized:] ()
#​7  0x000000010ff4a3c6 in NSKeyValuePropertyForIsaAndKeyPathInner ()
#​8  0x000000010ff4c364 in NSKeyValuePropertyForIsaAndKeyPath ()
#​9  0x000000010ff48e18 in _NSKeyValueCreateImplicitObservationInfo ()
#​10 0x000000010ff72bba in -[NSOperation init] ()
#​11 0x000000010ff204ab in +[NSFilesystemItemRemoveOperation filesystemItemRemoveOperationWithPath:] ()
#​12 0x000000010ff19d44 in -[NSFileManager removeItemAtPath:error:] ()
#​13 0x0000000113e53188 in TTConfigurationModelStorage.reset() at /Users/dstenmark/Work/ios/TTKit/Frameworks/Core/Library/Configuration/TTConfigurationModelStorage.swift:46
...

Thread 2 Queue : NSManagedObjectContext 0x60000036dfe0 (serial)
#​0  0x0000000112afb58d in flushCaches(objc_class*) ()
#​1  0x0000000112afd2cf in method_exchangeImplementations ()
#​2  0x0000000118aa8af4 in globalinit_33_6DA0945A07226B3278459E9368612FF4_func30 ()
#​3  0x0000000118f43d02 in _dispatch_client_callout ()
#​4  0x0000000118f454ce in _dispatch_once_callout ()
#​5  0x000000011855d579 in swift_once ()
#&#8203;6  0x0000000118aade57 in NSSortDescriptor.init<A, B>(keyPath:ascending:) ()
#&#8203;7  0x0000000113e0ee03 in closure #&#8203;1 in closure #&#8203;2 in TTInternalEventLogger.init(batchEventService:configuration:invalidStateLogger:) at /Users/dstenmark/Work/ios/TTKit/Frameworks/Core/Library/Events/FirstParty/TTInternalEventLogger.swift:172
...

This matches what's described in https://bugs.swift.org/browse/SR-6795, suggesting that the issue may not be fully resolved after all.

@belkadan
Copy link

As noted there, the fix didn't make it into Swift 5.0. It should be in Swift 5.1, though, so if you have the chance to test with the Xcode 11 beta you should be able to verify that the problem is gone.

@swift-ci
Copy link
Contributor Author

Comment by Dan Stenmark (JIRA)

Gotcha, thanks!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants