realm-swift
realm-swift copied to clipboard
Getting error with all versions past 10.20.0
How frequently does the bug occur?
All the time
Description
I'm getting an error when trying to load while filtering on a uuid
Stacktrace & log output
2022-08-18 12:26:22.004335-0600 RealmTest[16593:19905950] *** Terminating app due to uncaught exception 'RLMException', reason: 'Cannot convert value '(null)' of type '(null)' to uuid'
*** First throw call stack:
(
0 CoreFoundation 0x000000018040c2fc __exceptionPreprocess + 172
1 libobjc.A.dylib 0x000000018005131c objc_exception_throw + 56
2 RealmTest 0x0000000104766e5c _Z13RLMObjcToUUIDP11objc_object + 620
3 RealmTest 0x000000010446aeb0 _ZN27RLMStatelessAccessorContext5unboxIN5realm4UUIDEEET_P11objc_object + 80
4 RealmTest 0x00000001046cde34 _ZN12_GLOBAL__N_113value_of_typeIN5realm4UUIDEEEDaP11objc_object + 40
5 RealmTest 0x00000001046db24c _ZZN12_GLOBAL__N_112QueryBuilder17do_add_constraintINS_8IdentityERU8__strongKP11objc_objectEEv15RLMPropertyType23NSPredicateOperatorTypemRKNS_15ColumnReferenceEOT0_ENKUlOT_E7_clIS6_EEDaSF_ + 100
6 RealmTest 0x00000001046d8abc _ZN12_GLOBAL__N_112convert_nullIRU8__strongKP11objc_objectZNS_12QueryBuilder17do_add_constraintINS_8IdentityES4_EEv15RLMPropertyType23NSPredicateOperatorTypemRKNS_15ColumnReferenceEOT0_EUlOT_E7_EEvSG_SE_ + 68
7 RealmTest 0x00000001046c7c08 _ZN12_GLOBAL__N_112QueryBuilder17do_add_constraintINS_8IdentityERU8__strongKP11objc_objectEEv15RLMPropertyType23NSPredicateOperatorTypemRKNS_15ColumnReferenceEOT0_ + 796
8 RealmTest 0x00000001046a5344 _ZN12_GLOBAL__N_112QueryBuilder14add_constraintIU8__strongP11objc_objectEEv23NSPredicateOperatorTypemRKNS_15ColumnReferenceERKT_ + 428
9 RealmTest 0x00000001045916ac _ZN12_GLOBAL__N_112QueryBuilder22apply_value_expressionEONS_7KeyPathEP11objc_objectP21NSComparisonPredicate + 576
10 RealmTest 0x000000010458f010 _ZN12_GLOBAL__N_112QueryBuilder15apply_predicateEP11NSPredicateP15RLMObjectSchema + 2948
11 RealmTest 0x000000010458e6bc _ZN12_GLOBAL__N_112QueryBuilder15apply_predicateEP11NSPredicateP15RLMObjectSchema + 560
12 RealmTest 0x000000010458e17c _Z19RLMPredicateToQueryP11NSPredicateP15RLMObjectSchemaP9RLMSchemaRN5realm5GroupE + 260
13 RealmTest 0x000000010470d9e8 _ZZ35-[RLMResults objectsWithPredicate:]ENK4$_15clEv + 268
14 RealmTest 0x00000001047059e0 _ZL25translateRLMResultsErrorsIZ35-[RLMResults objectsWithPredicate:]E4$_15EDaOT_P8NSString + 36
15 RealmTest 0x0000000104705964 -[RLMResults objectsWithPredicate:] + 88
16 RealmTest 0x00000001047c9204 $s10RealmSwift0A14CollectionImplPAAE6filteryAA7ResultsVy7ElementQzGSo11NSPredicateCF + 192
17 RealmTest 0x000000010445974c $s9RealmTest01_A7StorageC7loadAll10filteredBy08distinctG8KeyPaths06sortedG009paginatedG0SayxGSo11NSPredicateCSg_SaySSGSgSayAA0C4SortVGSgAA0C10PaginationVSgtF + 520
18 RealmTest 0x000000010444a558 $s9RealmTest01_A18SyncActionProviderC17allForCurrentUser10filteredBySayxGSo11NSPredicateCSg_tF + 1164
19 RealmTest 0x00000001044473d0 $s9RealmTest9ViewModelC12getSyncItemsyyF + 60
20 RealmTest 0x00000001044465c8 $s9RealmTest11ContentViewV4bodyQrvg7SwiftUI05TupleD0VyAE0D0PAEE15foregroundColoryQrAE0J0VSgFQOyAiEE10imageScaleyQrAE5ImageV0L0OFQOyAP_Qo__Qo__AE4TextVAE6ButtonVyAVGtGyXEfU_yycfU_ + 76
21 SwiftUI 0x000000010c9a31f4 __swift_memcpy3_1 + 8096
22 SwiftUI 0x000000010c9a3a7c __swift_memcpy3_1 + 10280
23 SwiftUI 0x000000010c9a39ec __swift_memcpy3_1 + 10136
24 SwiftUI 0x000000010cd527e8 OUTLINED_FUNCTION_30 + 4452
25 SwiftUI 0x000000010cd52804 OUTLINED_FUNCTION_30 + 4480
26 SwiftUI 0x000000010cd527e8 OUTLINED_FUNCTION_30 + 4452
27 SwiftUI 0x000000010cac781c OUTLINED_FUNCTION_50 + 3052
28 SwiftUI 0x000000010cac72d4 OUTLINED_FUNCTION_50 + 1700
29 SwiftUI 0x000000010cc11894 OUTLINED_FUNCTION_11 + 1660
30 SwiftUI 0x000000010d2daa0c OUTLINED_FUNCTION_2 + 9296
31 SwiftUI 0x000000010d2d92b0 OUTLINED_FUNCTION_2 + 3316
32 SwiftUI 0x000000010d2d9388 OUTLINED_FUNCTION_2 + 3532
33 UIKitCore 0x0000000109252ef0 -[UIGestureRecognizer _componentsEnded:withEvent:] + 176
34 UIKitCore 0x00000001097147a8 -[UITouchesEvent _sendEventToGestureRecognizer:] + 556
35 UIKitCore 0x00000001092481f8 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 160
36 UIKitCore 0x0000000109247fe8 -[UIGestureEnvironment _updateForEvent:window:] + 156
37 UIKitCore 0x00000001096d1638 -[UIWindow sendEvent:] + 3168
38 UIKitCore 0x00000001096af7b8 -[UIApplication sendEvent:] + 692
39 UIKitCore 0x000000010972bba4 __dispatchPreprocessedEventFromEventQueue + 6828
40 UIKitCore 0x000000010972d808 __processEventQueue + 5612
41 UIKitCore 0x00000001097267ac __eventFetcherSourceCallback + 220
42 CoreFoundation 0x0000000180371094 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
43 CoreFoundation 0x0000000180370fdc __CFRunLoopDoSource0 + 172
44 CoreFoundation 0x000000018037074c __CFRunLoopDoSources0 + 232
45 CoreFoundation 0x000000018036ae8c __CFRunLoopRun + 756
46 CoreFoundation 0x000000018036a780 CFRunLoopRunSpecific + 584
47 GraphicsServices 0x0000000188f4dc98 GSEventRunModal + 160
48 UIKitCore 0x0000000109695c28 -[UIApplication _run] + 868
49 UIKitCore 0x0000000109699bd0 UIApplicationMain + 124
50 SwiftUI 0x000000010d297480 OUTLINED_FUNCTION_51 + 496
51 SwiftUI 0x000000010d297328 OUTLINED_FUNCTION_51 + 152
52 SwiftUI 0x000000010ca7f590 OUTLINED_FUNCTION_10 + 88
53 RealmTest 0x0000000104448aa0 $s9RealmTest0aB3AppV5$mainyyFZ + 40
54 RealmTest 0x0000000104448b44 main + 12
55 dyld 0x0000000108565fa0 start_sim + 20
56 ??? 0x000000010838908c 0x0 + 4432892044
57 ??? 0x0304800000000000 0x0 + 217439419508981760
)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'RLMException', reason: 'Cannot convert value '(null)' of type '(null)' to uuid'
terminating with uncaught exception of type NSException
CoreSimulator 857.7 - Device: iPhone 13 (D61A5388-F5EC-47B0-BE73-E0CF1AE8600B) - Runtime: iOS 16.0 (20A5339d) - DeviceType: iPhone 13
Can you reproduce the bug?
Yes, always
Reproduction Steps
Open the included project and click Get Sync Items
Version
10.28.5
What SDK flavour are you using?
Local Database only
Are you using encryption?
No, not using encryption
Platform OS and version(s)
iOS 15
Build environment
Xcode version: ... Dependency manager and version: ...
Here is the test project I created to reproduce the issue. I'm running this on M1 Pro MacBook Pro
This is an even simpler example. Seems like it fails any time you filter to a uuid using NSPredicate. It does work to use the new query method (as shown in this example project) but the NSPredicate fails
I've narrowed down to where the issue is:
RLMAccessor.mm: Line 991
realm::UUID RLMStatelessAccessorContext::unbox(id v) {
return RLMObjcToUUID(bridged<NSUUID>(v));
}
RLMAccessor.mm: Line 946
static T *bridged(__unsafe_unretained id const value) {
return [value isKindOfClass:[T class]] ? value : RLMBridgeSwiftValue(value);
}
RLMUtil.mm: Line 92
id RLMBridgeSwiftValue(__unsafe_unretained id value) {
if (!value || !RLMSwiftBridgeValue) {
return nil;
}
return RLMSwiftBridgeValue(value);
}
SchemaDiscovery.swift: Line 191
private static let runOnce: Void = {
RLMSwiftBridgeValue = { (value: Any) -> Any? in
// `as AnyObject` required on iOS <= 13; it will compile but silently
// fail to cast otherwise
if let value = value as AnyObject as? _ObjcBridgeable {
return value._rlmObjcValue
}
return nil
}
}()
The RLMSwiftBridgeValue
returns nil because the line if let value = value as AnyObject as? _ObjcBridgeable
fails
Hi @gbreen12 Thanks for the solid reproduction! We'll investigate the issue.
We are also affected by this issue
@leemaguire Is there any update on this?