Regex crash on `MR_findFirstWithPredicate` #684

Closed
xanderdunn opened this Issue Feb 25, 2014 · 4 comments

Projects

None yet

3 participants

@xanderdunn

I execute this:

NSPredicate *sameNameAndDescription = [NSPredicate predicateWithFormat:@"name LIKE %@ AND number LIKE %@", field1, field2];
return [Object MR_findFirstWithPredicate:sameNameAndDescription inContext:[NSManagedObjectContext MR_defaultContext]];

I get an exception:
2014-02-24 19:55:54.443 Memories[1209:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Can't do regex matching, reason: Can't open pattern U_REGEX_MISMATCHED_PAREN (string אֲנִי מְסֻגָּל(ת) ל-, pattern まみれ (塗れ) [まにれ], case 0, canon 0)'

It looks like it's caused specifically by the string "まみれ (塗れ) [まにれ]". Regardless of the other string it's being compared to, I get this exception.

Here is the stack trace at the moment of the exception:

Thread 1, Queue : NSManagedObjectContext Queue
#0  0x391301f0 in __pthread_kill ()
#1  0x391987b6 in pthread_kill ()
#2  0x390e0ff8 in abort ()
#3  0x3851398e in abort_message ()
#4  0x3852c6e6 in default_terminate_handler() ()
#5  0x38b5ff7c in _objc_terminate() ()
#6  0x3852a1b2 in std::__terminate(void (*)()) ()
#7  0x38529d16 in __cxa_rethrow ()
#8  0x38b5fe2e in objc_exception_rethrow ()
#9  0x2df42520 in -[NSManagedObjectContext executeFetchRequest:error:] ()
#10 0x2dfcfe1e in -[NSManagedObjectContext(_NestedContextSupport) _parentObjectsForFetchRequest:inContext:error:] ()
#11 0x2dfd0596 in __82-[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:]_block_invoke ()
#12 0x39064d3e in _dispatch_client_callout ()
#13 0x390696c2 in _dispatch_barrier_sync_f_invoke ()
#14 0x2dfc5ea2 in _perform ()
#15 0x2dfd0298 in -[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:] ()
#16 0x2df4193a in -[NSManagedObjectContext executeFetchRequest:error:] ()
#17 0x000f0dd8 in __67+[NSManagedObject(MagicalRecord) MR_executeFetchRequest:inContext:]_block_invoke at /local/dev/objc/memories/Pods/MagicalRecord/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalRecord.m:33
#18 0x2dfc89f4 in developerSubmittedBlockToNSManagedObjectContextPerform ()
#19 0x3906ab3a in _dispatch_barrier_sync_f_slow_invoke ()
#20 0x39064d3e in _dispatch_client_callout ()
#21 0x390676c2 in _dispatch_main_queue_callback_4CF ()
#22 0x2e1bb678 in __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ ()
#23 0x2e1b9f44 in __CFRunLoopRun ()
#24 0x2e1247a8 in CFRunLoopRunSpecific ()
#25 0x2e12458a in CFRunLoopRunInMode ()
#26 0x3325f6d2 in GSEventRunModal ()
#27 0x30c0a6d8 in UIApplicationMain ()
#28 0x0009d954 in main at /local/dev/objc/memories/LearningApp/SupportingFiles/main.m:16
Thread 2, Queue : com.apple.libdispatch-manager
#0  0x3911d804 in kevent64 ()
#1  0x3906c054 in _dispatch_mgr_invoke ()
#2  0x390662e2 in _dispatch_mgr_thread ()
Thread 7, Queue : com.apple.root.default-priority
#0  0x3911daa0 in semaphore_wait_trap ()
#1  0x39191a0c in _os_semaphore_wait ()
#2  0x39069512 in _dispatch_barrier_sync_f_slow ()
#3  0x2dfc8b32 in -[NSManagedObjectContext performBlockAndWait:] ()
#4  0x000f0c60 in +[NSManagedObject(MagicalRecord) MR_executeFetchRequest:inContext:] at /local/dev/objc/memories/Pods/MagicalRecord/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalRecord.m:29
#5  0x000f1018 in +[NSManagedObject(MagicalRecord) MR_executeFetchRequestAndReturnFirstObject:inContext:] at /local/dev/objc/memories/Pods/MagicalRecord/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalRecord.m:53
#6  0x000ef50e in +[NSManagedObject(MagicalFinders) MR_findFirstWithPredicate:inContext:] at /local/dev/objc/memories/Pods/MagicalRecord/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalFinders.m:128
#7  0x000a9ece in +[QAMemory existingQAMemoryWithQuestion:answer:context:] at /local/dev/objc/memories/LearningApp/CoreData/QAMemory.m:53
#8  0x000aa13a in +[QAMemory qaMemoryWithQuestion:answer:category:context:] at /local/dev/objc/memories/LearningApp/CoreData/QAMemory.m:74
#9  0x0009c554 in -[TAQuizletTerm memoryWithSupercategory:] at /local/dev/objc/memories/LearningApp/Model/TAQuizletTerm.m:44
#10 0x000d8b2e in -[TAQuizletSet subcategoryWithSupercategory:] at /local/dev/objc/memories/LearningApp/Model/TAQuizletSet.m:56
#11 0x000bedec in __50-[TAQuizletSetTableViewController selectCategory:]_block_invoke at /local/dev/objc/memories/LearningApp/ViewControllers/TAQuizletSetTableViewController.m:68
#12 0x39064d52 in _dispatch_call_block_and_release ()
#13 0x3906a688 in _dispatch_root_queue_drain ()
#14 0x3906a8dc in _dispatch_worker_thread2 ()
#15 0x39195c16 in _pthread_wqthread ()
Thread 8 com.apple.NSURLConnectionLoader, Queue : (null)
Thread 9 com.apple.CFSocket.private, Queue : (null)
Thread 10, Queue : (null)
Thread 11, Queue : (null)
Thread 12, Queue : (null)
Thread 13, Queue : (null)
@duoleimi

core data can not use "description" with a attribute name

@xanderdunn

The original code does not use description. I just changed the variable names when I copied over to GitHub. Sorry, that was my mistake in writing this issue. I fixed my original post.

@xanderdunn

This has nothing to do with MagicalRecord and everything to do with NSPredicate regex matching. In my case, I don't want any regex matching so I simply replaced the LIKE operators with == in my code and now it ignores the special characters in my string queries.

@xanderdunn xanderdunn closed this Mar 1, 2014
@MeganZhou

The issue is still exist, when i enter a chinese "c" to mapping "like", then it response me the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment