Hopefully someone can help me debug this problem as EXC_BAD_ACCESS is the only error I receive. I've also tried turning on NSZombieEnabled, but don't get any more information as far I can tell.
The problem. I have four entities:
A -> B -> C -> D
Where the arrow symbolizes a set: "A" contains a to-many relation to "B", "B" a to-many relation to "C" etc. For creating the entity I use:
id dto = [NSEntityDescription insertNewObjectForEntityForName:@"A"
inManagedObjectContext:context];
NSLog(@"DTO: %@", dto);
and this seems to work for A, B and C. However, when using it on entity D the app crashes with EXC_BAD_ACCESS. The problem seems to occur when accessing the object, as the program runs successfully when commenting out NSLog and other methods accessing the dto-object.
Console output
GNU gdb 6.3.50-20050815 (Apple version gdb-1346) (Fri Sep 18 20:40:51 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 3100.
Program received signal: “EXC_BAD_ACCESS”.
warning: Unable to restore previously selected frame.
No memory available to program now: unsafe to call malloc
warning: check_safe_call: could not restore current frame
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Not safe to call dlopen at this time.)
warning: Unable to restore previously selected frame.
Stack
The stack trace is very large (?), when debugging it loads "62826 stack frames". Showing a part of it:
Lines #8-#41 is repeated to around frame #62500.
So whenever there are that many stack frames, it means there is some sort of infinite recursion going on. My guess is that when creating a D object, there is some code that automatically creates something else, which in turn is creating another D and there is a loop that is unterminated. I would start by checking any Key Value Observers or NSManagedObject Overrides
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With