Hello guys,
I am trying to debug the following crash: [NSTaggedPointerString count]: unrecognized selector sent to instance 0x8000000000000000
Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x19af619d8 __exceptionPreprocess
1 libobjc.A.dylib 0x1af2e7b54 objc_exception_throw
2 CoreFoundation 0x19ae71bbc -[NSOrderedSet initWithSet:copyItems:]
3 CoreFoundation 0x19af6401c ___forwarding___
4 CoreFoundation 0x19af65f8c _CF_forwarding_prep_0
5 libswiftCore.dylib 0x19e9e4d70 Dictionary._Variant.updateValue(_:forKey:)
... More lines...
24 MyApplication 0x10424c23c main + 15 (AppDelegate.swift:15)
25 libdyld.dylib 0x19abb9568 start
The thing is that the stack trace and the crash reason changes in each report, some of the crash reason I have seen are:
- [NSTaggedPointerString count]: unrecognized selector sent to instance 0x8000000000000000
- -[__NSCFNumber count]: unrecognized selector sent to instance 0x8000000000000000
- EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000010
This seems to be related to some thread safety issues based on some other threads: https://developer.apple.com/forums/thread/116028
I am attaching an implementation sample of what the code is doing right now
Basically, the code where this crash is happening is using a DispatchGroup
object, before calling the .leave()
method, this is updating a dictionary property that was declared before. At that point, the code seems to be running on another thread which is causing the issue.
If this is a thread issue, what are my options here? What would be the easiest thing to fix this issue?
Thanks in advance!!