RaiseMan exits with Bad Access


#1

I entered the code for RaiseMan and started the Application as described on page 139. After pressing the add employees button the application crashes with “Bad Access”. I checked all my classes at least twice now and also checked the bindings that I have set. As everything seemed to look ok, I did some debugging and that told me, that the application passes the init method of Person and crashes right after it. A look in the details tells, that the crash obiously happens here: [ NSArrayController _executeAdd:didCommitSuccessfully:actionSender]
What might I have done wrong?

//Edit Meanwhile I have an idea, why this might have gone wrong: I am using XCode 4.2 with SnowLeopard at the moment. Do I have to use Lion for the examples to be working?

Btw, the stacktrace looks like this:
0x00007fff819ef36b <+0000> push %rbp
0x00007fff819ef36c <+0001> mov %rsp,%rbp
0x00007fff819ef36f <+0004> mov %rbx,-0x28(%rbp)
0x00007fff819ef373 <+0008> mov %r12,-0x20(%rbp)
0x00007fff819ef377 <+0012> mov %r13,-0x18(%rbp)
0x00007fff819ef37b <+0016> mov %r14,-0x10(%rbp)
0x00007fff819ef37f <+0020> mov %r15,-0x8(%rbp)
0x00007fff819ef383 <+0024> sub $0x30,%rsp
0x00007fff819ef387 <+0028> mov %rdi,%r12
0x00007fff819ef38a <+0031> mov %r8,%r14
0x00007fff819ef38d <+0034> mov %ecx,%ebx
0x00007fff819ef38f <+0036> mov -0x1171613e(%rip),%rsi # 0x7fff702d9258
0x00007fff819ef396 <+0043> callq 0x7fff81e72842 <dyld_stub_objc_msgSend>
0x00007fff819ef39b <+0048> test %al,%al
0x00007fff819ef39d <+0050> je 0x7fff819ef4d9 <-[NSArrayController _executeAdd:didCommitSuccessfully:actionSender:]+366>
0x00007fff819ef3a3 <+0056> test %bl,%bl
0x00007fff819ef3a5 <+0058> je 0x7fff819ef4d9 <-[NSArrayController _executeAdd:didCommitSuccessfully:actionSender:]+366>
0x00007fff819ef3ab <+0064> mov -0x11716142(%rip),%rsi # 0x7fff702d9270
0x00007fff819ef3b2 <+0071> mov %r12,%rdi
0x00007fff819ef3b5 <+0074> callq 0x7fff81e72842 <dyld_stub_objc_msgSend>
0x00007fff819ef3ba <+0079> mov %rax,%r13 [color=#FF0000]<<< Crash here!!![/color]
0x00007fff819ef3bd <+0082> test %rax,%rax
0x00007fff819ef3c0 <+0085> je 0x7fff819ef4b8 <-[NSArrayController _executeAdd:didCommitSuccessfully:actionSender:]+333>
0x00007fff819ef3c6 <+0091> mov -0x11715c45(%rip),%rsi # 0x7fff702d9788
0x00007fff819ef3cd <+0098> mov %r12,%rdi
0x00007fff819ef3d0 <+0101> callq 0x7fff81e72842 <dyld_stub_objc_msgSend>
0x00007fff819ef3d5 <+0106> mov %rax,%rdi
0x00007fff819ef3d8 <+0109> mov -0x11715c5f(%rip),%rsi # 0x7fff702d9780
0x00007fff819ef3df <+0116> callq 0x7fff81e72842 <dyld_stub_objc_msgSend>
0x00007fff819ef3e4 <+0121> mov 0x7fffffffffffffff,%rdx 0x00007fff819ef3ee <+0131> cmp %rdx,%rax 0x00007fff819ef3f1 <+0134> jne 0x7fff819ef402 <-[NSArrayController _executeAdd:didCommitSuccessfully:actionSender:]+151> 0x00007fff819ef3f3 <+0136> mov -0x11715c3a(%rip),%rsi # 0x7fff702d97c0 0x00007fff819ef3fa <+0143> mov %r12,%rdi 0x00007fff819ef3fd <+0146> callq 0x7fff81e72842 <dyld_stub_objc_msgSend> 0x00007fff819ef402 <+0151> lea -0x1167ff79(%rip),%r15 # 0x7fff7036f490 <OBJC_IVAR__NSObjectController._objectHandler>
0x00007fff819ef409 <+0158> mov (%r15),%rax
0x00007fff819ef40c <+0161> mov (%r12,%rax,1),%rdi
0x00007fff819ef410 <+0165> test %rdi,%rdi
0x00007fff819ef413 <+0168> je 0x7fff819ef424 <-[NSArrayController _executeAdd:didCommitSuccessfully:actionSender:]+185>
0x00007fff819ef415 <+0170> mov -0x117161b4(%rip),%rsi # 0x7fff702d9268
0x00007fff819ef41c <+0177> mov %r14,%rdx
0x00007fff819ef41f <+0180> callq 0x7fff81e72842 <dyld_stub_objc_msgSend>
0x00007fff819ef424 <+0185> mov %r13,%rdx
0x00007fff819ef427 <+0188> lea -0x11718ac6(%rip),%rsi # 0x7fff702d6968
0x00007fff819ef42e <+0195> mov %r12,%rdi
0x00007fff819ef431 <+0198> callq *-0x11718acf(%rip) # 0x7fff702d6968
0x00007fff819ef437 <+0204> jmp 0x7fff819ef463 <-[NSArrayController _executeAdd:didCommitSuccessfully:actionSender:]+248>
0x00007fff819ef439 <+0206> mov %rax,%rbx
0x00007fff819ef43c <+0209> dec %rdx
0x00007fff819ef43f <+0212> jne 0x7fff819ef45b <-[NSArrayController _executeAdd:didCommitSuccessfully:actionSender:]+240>
0x00007fff819ef441 <+0214> mov %rax,%rdi
0x00007fff819ef444 <+0217> callq 0x7fff81e727e2 <dyld_stub_objc_begin_catch>
0x00007fff819ef449 <+0222> mov %rax,%rbx
0x00007fff819ef44c <+0225> callq 0x7fff81e72806 <dyld_stub_objc_end_catch>
0x00007fff819ef451 <+0230> jmp 0x7fff819ef465 <-[NSArrayController _executeAdd:didCommitSuccessfully:actionSender:]+250>
0x00007fff819ef453 <+0232> mov %rax,%rbx
0x00007fff819ef456 <+0235> callq 0x7fff81e72806 <dyld_stub_objc_end_catch>
0x00007fff819ef45b <+0240> mov %rbx,%rdi
0x00007fff819ef45e <+0243> callq 0x7fff81e72470 <dyld_stub__Unwind_Resume>
0x00007fff819ef463 <+0248> xor %ebx,%ebx
0x00007fff819ef465 <+0250> mov (%r15),%rax
0x00007fff819ef468 <+0253> mov (%r12,%rax,1),%rdi
0x00007fff819ef46c <+0257> test %rdi,%rdi
0x00007fff819ef46f <+0260> je 0x7fff819ef47f <-[NSArrayController _executeAdd:didCommitSuccessfully:actionSender:]+276>
0x00007fff819ef471 <+0262> mov -0x11716210(%rip),%rsi # 0x7fff702d9268
0x00007fff819ef478 <+0269> xor %edx,%edx
0x00007fff819ef47a <+0271> callq 0x7fff81e72842 <dyld_stub_objc_msgSend>
0x00007fff819ef47f <+0276> lea -0x11718c0e(%rip),%rsi # 0x7fff702d6878
0x00007fff819ef486 <+0283> mov %r13,%rdi
0x00007fff819ef489 <+0286> callq *-0x11718c17(%rip) # 0x7fff702d6878
0x00007fff819ef48f <+0292> test %rbx,%rbx
0x00007fff819ef492 <+0295> je 0x7fff819ef4d9 <-[NSArrayController _executeAdd:didCommitSuccessfully:actionSender:]+366>
0x00007fff819ef494 <+0297> mov -0x11717fbb(%rip),%rsi # 0x7fff702d74e0
0x00007fff819ef49b <+0304> mov %rbx,%rdi
0x00007fff819ef49e <+0307> mov -0x28(%rbp),%rbx
0x00007fff819ef4a2 <+0311> mov -0x20(%rbp),%r12
0x00007fff819ef4a6 <+0315> mov -0x18(%rbp),%r13
0x00007fff819ef4aa <+0319> mov -0x10(%rbp),%r14
0x00007fff819ef4ae <+0323> mov -0x8(%rbp),%r15
0x00007fff819ef4b2 <+0327> leaveq
0x00007fff819ef4b3 <+0328> jmpq 0x7fff81e72842 <dyld_stub_objc_msgSend>
0x00007fff819ef4b8 <+0333> lea -0x11765097(%rip),%rdi # 0x7fff7028a428
0x00007fff819ef4bf <+0340> mov -0x28(%rbp),%rbx
0x00007fff819ef4c3 <+0344> mov -0x20(%rbp),%r12
0x00007fff819ef4c7 <+0348> mov -0x18(%rbp),%r13
0x00007fff819ef4cb <+0352> mov -0x10(%rbp),%r14
0x00007fff819ef4cf <+0356> mov -0x8(%rbp),%r15
0x00007fff819ef4d3 <+0360> leaveq
0x00007fff819ef4d4 <+0361> jmpq 0x7fff81d78e17 <_NSHandleBindingException>
0x00007fff819ef4d9 <+0366> mov -0x28(%rbp),%rbx
0x00007fff819ef4dd <+0370> mov -0x20(%rbp),%r12
0x00007fff819ef4e1 <+0374> mov -0x18(%rbp),%r13
0x00007fff819ef4e5 <+0378> mov -0x10(%rbp),%r14
0x00007fff819ef4e9 <+0382> mov -0x8(%rbp),%r15
0x00007fff819ef4ed <+0386> leaveq
0x00007fff819ef4ee <+0387> retq


#2

Hi, I am running into the same problem – I’ve checked all code, settings and bindings couple of times. As soon as _executeAdd is called the applications exists with Bad Access. I am running Lion with Xcode 4.1. Can someone share a working version ? I would like to check my files against the working source code - maybe this gives a hint what went wrong.
BRgds /alex


#3

As pointed out in the beginning of the book, this edition really does require you use Xcode 4.2 or better. Otherwise you have enter all of the memory management code that is being handled by ARC and is not covered in this edition of the book.


#4

Thanks a lot the hint about the memory management code - you are fully right. I’m now using Xcode 4.2 and it’s working fine.


#5

Ok, it’s all done now: I updated to Lion and tatatata… it works! :slight_smile:


#6

I am getting the same “Bad Access” crash when I click the “Add Employee” button in the RaiseMan application (chapter 8). I am using XCode 4.2.1; and I just updated my OS to Lion 10.7.3, since mholste’s last comment sounded so positive. I’m wondering whether the upgrade to Lion was really necessary. (Perhaps it was a good idea to update it, anyway.) Maybe Mr. Preble can chip in here and offer some direction. I’ve gone through the book with a fine-toothed comb to make sure I’ve typed everything correctly, checking-off each paragraph in the book with a pencil; but I can’t see anything wrong with my code. The source files are in the right place, and the bindings are all hooked up. Maybe I could post my code, zipped, with screen-shots (or window-shots), if desired. I hope I can get RaiseMan working before moving on; I hate moving to the next section/chapter when I haven’t really finished the previous one.


#7

Hi davo123,

Sorry for the delay – can you post any messages that accompanied the crash in the console, as well as the stack trace? You can get the stack trace using “bt” in the debugger console, or by selecting the stack frames in the Debug Navigator and hitting Command-C (copy).

Adam


#8

MESSAGES ACCOMPANYING CRASH IN THE CONSOLE:

GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Thu Nov 3 21:59:02 UTC 2011)
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”.tty /dev/ttys000
[Switching to process 2263 thread 0x0]
2012-02-08 13:09:37.923 SpeakLine[2263:707] init
2012-02-08 13:09:38.177 SpeakLine[2263:707] -[NSConcreteMapTable objectAtIndex:]: unrecognized selector sent to instance 0x100315380
2012-02-08 13:09:38.181 SpeakLine[2263:707] -[NSConcreteMapTable objectAtIndex:]: unrecognized selector sent to instance 0x100315380
2012-02-08 13:09:38.192 SpeakLine[2263:707] (
0 CoreFoundation 0x00007fff83918fc6 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff843c3d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff839a52ae -[NSObject doesNotRecognizeSelector:] + 190
3 CoreFoundation 0x00007fff83905e73 forwarding + 371
4 CoreFoundation 0x00007fff83905c88 _CF_forwarding_prep_0 + 232
5 SpeakLine 0x0000000100002022 -[SpeakLineAppDelegate tableView:objectValueForTableColumn:row:] + 66
6 AppKit 0x00007fff877e711b -[NSTableView _dataSourceValueForColumn:row:] + 73
7 AppKit 0x00007fff877e6b9b -[NSTableView preparedCellAtColumn:row:] + 437
8 AppKit 0x00007fff877f7ca5 -[NSTableView _drawContentsAtRow:column:withCellFrame:] + 42
9 AppKit 0x00007fff877f610c -[NSTableView drawRow:clipRect:] + 1647
10 AppKit 0x00007fff877f58e9 -[NSTableView drawRowIndexes:clipRect:] + 565
11 AppKit 0x00007fff877f3a0b -[NSTableView drawRect:] + 1390
12 AppKit 0x00007fff8775aabe -[NSView _drawRect:clip:] + 3758
13 AppKit 0x00007fff877881eb -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 1583
14 AppKit 0x00007fff87788617 -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2651
15 AppKit 0x00007fff87758099 -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 1032
16 AppKit 0x00007fff8775934e -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5821
17 AppKit 0x00007fff8775934e -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5821
18 AppKit 0x00007fff8775934e -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5821
19 AppKit 0x00007fff87757593 -[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 270
20 AppKit 0x00007fff877529af -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 4755
21 AppKit 0x00007fff8774b429 -[NSView displayIfNeeded] + 1676
22 AppKit 0x00007fff8774ab69 _handleWindowNeedsDisplayOrLayoutOrUpdateConstraints + 648
23 Foundation 0x00007fff8d2cdf64 __NSFireTimer + 102
24 CoreFoundation 0x00007fff838cdc24 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 20
25 CoreFoundation 0x00007fff838cd776 __CFRunLoopDoTimer + 534
26 CoreFoundation 0x00007fff838ae001 __CFRunLoopRun + 1617
27 CoreFoundation 0x00007fff838ad676 CFRunLoopRunSpecific + 230
28 HIToolbox 0x00007fff85b8331f RunCurrentEventLoopInMode + 277
29 HIToolbox 0x00007fff85b8a5c9 ReceiveNextEventCommon + 355
30 HIToolbox 0x00007fff85b8a456 BlockUntilNextEventMatchingListInMode + 62
31 AppKit 0x00007fff8770ef5d _DPSNextEvent + 659
32 AppKit 0x00007fff8770e861 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
33 AppKit 0x00007fff8770b19d -[NSApplication run] + 470
34 AppKit 0x00007fff87989b88 NSApplicationMain + 867
35 SpeakLine 0x0000000100001c52 main + 34
36 SpeakLine 0x0000000100001c24 start + 52
37 ??? 0x0000000000000003 0x0 + 3
)
2012-02-08 13:09:38.250 SpeakLine[2263:707] -[NSConcreteMapTable objectAtIndex:]: unrecognized selector sent to instance 0x100315380
2012-02-08 13:09:38.251 SpeakLine[2263:707] -[NSConcreteMapTable objectAtIndex:]: unrecognized selector sent to instance 0x100315380
2012-02-08 13:09:38.256 SpeakLine[2263:707] (
0 CoreFoundation 0x00007fff83918fc6 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff843c3d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff839a52ae -[NSObject doesNotRecognizeSelector:] + 190
3 CoreFoundation 0x00007fff83905e73 forwarding + 371
4 CoreFoundation 0x00007fff83905c88 _CF_forwarding_prep_0 + 232
5 SpeakLine 0x0000000100002022 -[SpeakLineAppDelegate tableView:objectValueForTableColumn:row:] + 66
6 AppKit 0x00007fff877e711b -[NSTableView _dataSourceValueForColumn:row:] + 73
7 AppKit 0x00007fff877e6b9b -[NSTableView preparedCellAtColumn:row:] + 437
8 AppKit 0x00007fff877f7ca5 -[NSTableView _drawContentsAtRow:column:withCellFrame:] + 42
9 AppKit 0x00007fff877f610c -[NSTableView drawRow:clipRect:] + 1647
10 AppKit 0x00007fff877f58e9 -[NSTableView drawRowIndexes:clipRect:] + 565
11 AppKit 0x00007fff877f3a0b -[NSTableView drawRect:] + 1390
12 AppKit 0x00007fff8775aabe -[NSView _drawRect:clip:] + 3758
13 AppKit 0x00007fff877881eb -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 1583
14 AppKit 0x00007fff87788617 -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2651
15 AppKit 0x00007fff87758099 -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 1032
16 AppKit 0x00007fff8775934e -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5821
17 AppKit 0x00007fff8775934e -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5821
18 AppKit 0x00007fff8775934e -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5821
19 AppKit 0x00007fff87757593 -[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 270
20 AppKit 0x00007fff877529af -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 4755
21 AppKit 0x00007fff8774b429 -[NSView displayIfNeeded] + 1676
22 AppKit 0x00007fff877471d2 -[NSAnimationManager animationTimerFired:] + 2593
23 Foundation 0x00007fff8d2cdf64 __NSFireTimer + 102
24 CoreFoundation 0x00007fff838cdc24 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 20
25 CoreFoundation 0x00007fff838cd776 __CFRunLoopDoTimer + 534
26 CoreFoundation 0x00007fff838ae001 __CFRunLoopRun + 1617
27 CoreFoundation 0x00007fff838ad676 CFRunLoopRunSpecific + 230
28 HIToolbox 0x00007fff85b8331f RunCurrentEventLoopInMode + 277
29 HIToolbox 0x00007fff85b8a5c9 ReceiveNextEventCommon + 355
30 HIToolbox 0x00007fff85b8a456 BlockUntilNextEventMatchingListInMode + 62
31 AppKit 0x00007fff8770ef5d _DPSNextEvent + 659
32 AppKit 0x00007fff8770e861 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
33 AppKit 0x00007fff8770b19d -[NSApplication run] + 470
34 AppKit 0x00007fff87989b88 NSApplicationMain + 867
35 SpeakLine 0x0000000100001c52 main + 34
36 SpeakLine 0x0000000100001c24 start + 52
37 ??? 0x0000000000000003 0x0 + 3
)
2012-02-08 13:09:38.341 SpeakLine[2263:707] -[NSConcreteMapTable objectAtIndex:]: unrecognized selector sent to instance 0x100315380
2012-02-08 13:09:38.342 SpeakLine[2263:707] -[NSConcreteMapTable objectAtIndex:]: unrecognized selector sent to instance 0x100315380
2012-02-08 13:09:38.345 SpeakLine[2263:707] (
0 CoreFoundation 0x00007fff83918fc6 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff843c3d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff839a52ae -[NSObject doesNotRecognizeSelector:] + 190
3 CoreFoundation 0x00007fff83905e73 forwarding + 371
4 CoreFoundation 0x00007fff83905c88 _CF_forwarding_prep_0 + 232
5 SpeakLine 0x0000000100002022 -[SpeakLineAppDelegate tableView:objectValueForTableColumn:row:] + 66
6 AppKit 0x00007fff877e711b -[NSTableView _dataSourceValueForColumn:row:] + 73
7 AppKit 0x00007fff877e6b9b -[NSTableView preparedCellAtColumn:row:] + 437
8 AppKit 0x00007fff8777e1bd -[NSTableView _dirtyVisibleCellsForKeyStateChange] + 612
9 AppKit 0x00007fff8777d755 -[NSTableView _windowChangedKeyState] + 294
10 CoreFoundation 0x00007fff838a6ea4 CFArrayApplyFunction + 68
11 AppKit 0x00007fff8777be4a -[NSView _windowChangedKeyState] + 185
12 CoreFoundation 0x00007fff838a6ea4 CFArrayApplyFunction + 68
13 AppKit 0x00007fff8777be4a -[NSView _windowChangedKeyState] + 185
14 CoreFoundation 0x00007fff838a6ea4 CFArrayApplyFunction + 68
15 AppKit 0x00007fff8777be4a -[NSView _windowChangedKeyState] + 185
16 CoreFoundation 0x00007fff838a6ea4 CFArrayApplyFunction + 68
17 AppKit 0x00007fff8777be4a -[NSView _windowChangedKeyState] + 185
18 AppKit 0x00007fff8777bd1e -[NSFrameView _windowChangedKeyState] + 92
19 AppKit 0x00007fff8777bbd7 -[NSWindow _setFrameNeedsDisplay:] + 163
20 AppKit 0x00007fff8780e532 _NXShowKeyAndMain + 167
21 AppKit 0x00007fff877743f1 -[NSApplication sendEvent:] + 2141
22 AppKit 0x00007fff8770b1f2 -[NSApplication run] + 555
23 AppKit 0x00007fff87989b88 NSApplicationMain + 867
24 SpeakLine 0x0000000100001c52 main + 34
25 SpeakLine 0x0000000100001c24 start + 52
26 ??? 0x0000000000000003 0x0 + 3
)
2012-02-08 13:09:38.354 SpeakLine[2263:707] -[NSConcreteMapTable objectAtIndex:]: unrecognized selector sent to instance 0x100315380
2012-02-08 13:09:38.355 SpeakLine[2263:707] -[NSConcreteMapTable objectAtIndex:]: unrecognized selector sent to instance 0x100315380
2012-02-08 13:09:38.359 SpeakLine[2263:707] (
0 CoreFoundation 0x00007fff83918fc6 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff843c3d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff839a52ae -[NSObject doesNotRecognizeSelector:] + 190
3 CoreFoundation 0x00007fff83905e73 forwarding + 371
4 CoreFoundation 0x00007fff83905c88 _CF_forwarding_prep_0 + 232
5 SpeakLine 0x0000000100002022 -[SpeakLineAppDelegate tableView:objectValueForTableColumn:row:] + 66
6 AppKit 0x00007fff877e711b -[NSTableView _dataSourceValueForColumn:row:] + 73
7 AppKit 0x00007fff877e6b9b -[NSTableView preparedCellAtColumn:row:] + 437
8 AppKit 0x00007fff877f7ca5 -[NSTableView _drawContentsAtRow:column:withCellFrame:] + 42
9 AppKit 0x00007fff877f610c -[NSTableView drawRow:clipRect:] + 1647
10 AppKit 0x00007fff877f58e9 -[NSTableView drawRowIndexes:clipRect:] + 565
11 AppKit 0x00007fff877f3a0b -[NSTableView drawRect:] + 1390
12 AppKit 0x00007fff8775aabe -[NSView _drawRect:clip:] + 3758
13 AppKit 0x00007fff877881eb -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 1583
14 AppKit 0x00007fff87788617 -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2651
15 AppKit 0x00007fff87758099 -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 1032
16 AppKit 0x00007fff8775934e -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5821
17 AppKit 0x00007fff8775934e -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5821
18 AppKit 0x00007fff8775934e -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5821
19 AppKit 0x00007fff87757593 -[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 270
20 AppKit 0x00007fff877529af -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 4755
21 AppKit 0x00007fff8774b429 -[NSView displayIfNeeded] + 1676
22 AppKit 0x00007fff8774ab69 _handleWindowNeedsDisplayOrLayoutOrUpdateConstraints + 648
23 CoreFoundation 0x00007fff838d8bd7 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
24 CoreFoundation 0x00007fff838d8b36 __CFRunLoopDoObservers + 374
25 CoreFoundation 0x00007fff838adce9 __CFRunLoopRun + 825
26 CoreFoundation 0x00007fff838ad676 CFRunLoopRunSpecific + 230
27 HIToolbox 0x00007fff85b8331f RunCurrentEventLoopInMode + 277
28 HIToolbox 0x00007fff85b8a51b ReceiveNextEventCommon + 181
29 HIToolbox 0x00007fff85b8a456 BlockUntilNextEventMatchingListInMode + 62
30 AppKit 0x00007fff8770ef5d _DPSNextEvent + 659
31 AppKit 0x00007fff8770e861 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
32 AppKit 0x00007fff8770b19d -[NSApplication run] + 470
33 AppKit 0x00007fff87989b88 NSApplicationMain + 867
34 SpeakLine 0x0000000100001c52 main + 34
35 SpeakLine 0x0000000100001c24 start + 52
36 ??? 0x0000000000000003 0x0 + 3
)
2012-02-08 13:09:39.173 SpeakLine[2263:707] -[NSConcreteMapTable objectAtIndex:]: unrecognized selector sent to instance 0x100315380
2012-02-08 13:09:39.175 SpeakLine[2263:707] -[NSConcreteMapTable objectAtIndex:]: unrecognized selector sent to instance 0x100315380
2012-02-08 13:09:39.182 SpeakLine[2263:707] (
0 CoreFoundation 0x00007fff83918fc6 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff843c3d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff839a52ae -[NSObject doesNotRecognizeSelector:] + 190
3 CoreFoundation 0x00007fff83905e73 forwarding + 371
4 CoreFoundation 0x00007fff83905c88 _CF_forwarding_prep_0 + 232
5 SpeakLine 0x0000000100002022 -[SpeakLineAppDelegate tableView:objectValueForTableColumn:row:] + 66
6 AppKit 0x00007fff877e711b -[NSTableView _dataSourceValueForColumn:row:] + 73
7 AppKit 0x00007fff877e6b9b -[NSTableView preparedCellAtColumn:row:] + 437
8 AppKit 0x00007fff877f7ca5 -[NSTableView _drawContentsAtRow:column:withCellFrame:] + 42
9 AppKit 0x00007fff877f610c -[NSTableView drawRow:clipRect:] + 1647
10 AppKit 0x00007fff877f58e9 -[NSTableView drawRowIndexes:clipRect:] + 565
11 AppKit 0x00007fff877f3a0b -[NSTableView drawRect:] + 1390
12 AppKit 0x00007fff8775aabe -[NSView _drawRect:clip:] + 3758
13 AppKit 0x00007fff877881eb -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 1583
14 AppKit 0x00007fff87788617 -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2651
15 AppKit 0x00007fff87758099 -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 1032
16 AppKit 0x00007fff8775934e -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5821
17 AppKit 0x00007fff8775934e -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5821
18 AppKit 0x00007fff8775934e -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5821
19 AppKit 0x00007fff87757593 -[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 270
20 AppKit 0x00007fff877529af -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 4755
21 AppKit 0x00007fff8774b429 -[NSView displayIfNeeded] + 1676
22 AppKit 0x00007fff8774ab69 _handleWindowNeedsDisplayOrLayoutOrUpdateConstraints + 648
23 CoreFoundation 0x00007fff838d8bd7 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
24 CoreFoundation 0x00007fff838d8b36 __CFRunLoopDoObservers + 374
25 CoreFoundation 0x00007fff838adce9 __CFRunLoopRun + 825
26 CoreFoundation 0x00007fff838ad676 CFRunLoopRunSpecific + 230
27 HIToolbox 0x00007fff85b8331f RunCurrentEventLoopInMode + 277
28 HIToolbox 0x00007fff85b8a5c9 ReceiveNextEventCommon + 355
29 HIToolbox 0x00007fff85b8a456 BlockUntilNextEventMatchingListInMode + 62
30 AppKit 0x00007fff8770ef5d _DPSNextEvent + 659
31 AppKit 0x00007fff8770e861 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
32 AppKit 0x00007fff8770b19d -[NSApplication run] + 470
33 AppKit 0x00007fff87989b88 NSApplicationMain + 867
34 SpeakLine 0x0000000100001c52 main + 34
35 SpeakLine 0x0000000100001c24 start + 52
36 ??? 0x0000000000000003 0x0 + 3
)
2012-02-08 13:09:46.196 SpeakLine[2263:707] -[NSConcreteMapTable objectAtIndex:]: unrecognized selector sent to instance 0x100315380
2012-02-08 13:09:46.197 SpeakLine[2263:707] -[NSConcreteMapTable objectAtIndex:]: unrecognized selector sent to instance 0x100315380
2012-02-08 13:09:46.203 SpeakLine[2263:707] (
0 CoreFoundation 0x00007fff83918fc6 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff843c3d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff839a52ae -[NSObject doesNotRecognizeSelector:] + 190
3 CoreFoundation 0x00007fff83905e73 forwarding + 371
4 CoreFoundation 0x00007fff83905c88 _CF_forwarding_prep_0 + 232
5 SpeakLine 0x0000000100002022 -[SpeakLineAppDelegate tableView:objectValueForTableColumn:row:] + 66
6 AppKit 0x00007fff877e711b -[NSTableView _dataSourceValueForColumn:row:] + 73
7 AppKit 0x00007fff877e6b9b -[NSTableView preparedCellAtColumn:row:] + 437
8 AppKit 0x00007fff8777e1bd -[NSTableView _dirtyVisibleCellsForKeyStateChange] + 612
9 AppKit 0x00007fff8777d755 -[NSTableView _windowChangedKeyState] + 294
10 CoreFoundation 0x00007fff838a6ea4 CFArrayApplyFunction + 68
11 AppKit 0x00007fff8777be4a -[NSView _windowChangedKeyState] + 185
12 CoreFoundation 0x00007fff838a6ea4 CFArrayApplyFunction + 68
13 AppKit 0x00007fff8777be4a -[NSView _windowChangedKeyState] + 185
14 CoreFoundation 0x00007fff838a6ea4 CFArrayApplyFunction + 68
15 AppKit 0x00007fff8777be4a -[NSView _windowChangedKeyState] + 185
16 CoreFoundation 0x00007fff838a6ea4 CFArrayApplyFunction + 68
17 AppKit 0x00007fff8777be4a -[NSView _windowChangedKeyState] + 185
18 AppKit 0x00007fff8777bd1e -[NSFrameView _windowChangedKeyState] + 92
19 AppKit 0x00007fff8777bbd7 -[NSWindow _setFrameNeedsDisplay:] + 163
20 AppKit 0x00007fff8777a25c endKeyAndMain + 119
21 AppKit 0x00007fff87774702 -[NSApplication sendEvent:] + 2926
22 AppKit 0x00007fff8770b1f2 -[NSApplication run] + 555
23 AppKit 0x00007fff87989b88 NSApplicationMain + 867
24 SpeakLine 0x0000000100001c52 main + 34
25 SpeakLine 0x0000000100001c24 start + 52
26 ??? 0x0000000000000003 0x0 + 3
)
2012-02-08 13:09:46.279 SpeakLine[2263:707] -[NSConcreteMapTable objectAtIndex:]: unrecognized selector sent to instance 0x100315380
2012-02-08 13:09:46.280 SpeakLine[2263:707] -[NSConcreteMapTable objectAtIndex:]: unrecognized selector sent to instance 0x100315380
2012-02-08 13:09:46.285 SpeakLine[2263:707] (
0 CoreFoundation 0x00007fff83918fc6 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff843c3d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff839a52ae -[NSObject doesNotRecognizeSelector:] + 190
3 CoreFoundation 0x00007fff83905e73 forwarding + 371
4 CoreFoundation 0x00007fff83905c88 _CF_forwarding_prep_0 + 232
5 SpeakLine 0x0000000100002022 -[SpeakLineAppDelegate tableView:objectValueForTableColumn:row:] + 66
6 AppKit 0x00007fff877e711b -[NSTableView _dataSourceValueForColumn:row:] + 73
7 AppKit 0x00007fff877e6b9b -[NSTableView preparedCellAtColumn:row:] + 437
8 AppKit 0x00007fff877f7ca5 -[NSTableView _drawContentsAtRow:column:withCellFrame:] + 42
9 AppKit 0x00007fff877f610c -[NSTableView drawRow:clipRect:] + 1647
10 AppKit 0x00007fff877f58e9 -[NSTableView drawRowIndexes:clipRect:] + 565
11 AppKit 0x00007fff877f3a0b -[NSTableView drawRect:] + 1390
12 AppKit 0x00007fff8775aabe -[NSView _drawRect:clip:] + 3758
13 AppKit 0x00007fff877881eb -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 1583
14 AppKit 0x00007fff87788617 -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2651
15 AppKit 0x00007fff87758099 -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 1032
16 AppKit 0x00007fff8775934e -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5821
17 AppKit 0x00007fff8775934e -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5821
18 AppKit 0x00007fff8775934e -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5821
19 AppKit 0x00007fff87757593 -[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 270
20 AppKit 0x00007fff877529af -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 4755
21 AppKit 0x00007fff8774b429 -[NSView displayIfNeeded] + 1676
22 AppKit 0x00007fff8774ab69 _handleWindowNeedsDisplayOrLayoutOrUpdateConstraints + 648
23 CoreFoundation 0x00007fff838d8bd7 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
24 CoreFoundation 0x00007fff838d8b36 __CFRunLoopDoObservers + 374
25 CoreFoundation 0x00007fff838adce9 __CFRunLoopRun + 825
26 CoreFoundation 0x00007fff838ad676 CFRunLoopRunSpecific + 230
27 HIToolbox 0x00007fff85b8331f RunCurrentEventLoopInMode + 277
28 HIToolbox 0x00007fff85b8a51b ReceiveNextEventCommon + 181
29 HIToolbox 0x00007fff85b8a456 BlockUntilNextEventMatchingListInMode + 62
30 AppKit 0x00007fff8770ef5d _DPSNextEvent + 659
31 AppKit 0x00007fff8770e861 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
32 AppKit 0x00007fff8770b19d -[NSApplication run] + 470
33 AppKit 0x00007fff87989b88 NSApplicationMain + 867
34 SpeakLine 0x0000000100001c52 main + 34
35 SpeakLine 0x0000000100001c24 start + 52
36 ??? 0x0000000000000003 0x0 + 3
)

STACK TRACE (from using ‘bt’ in the debugger console):

#0 0x00007fff843b8290 in objc_msgSend_vtable10 ()
#1 0x0000000100002022 in -[SpeakLineAppDelegate tableView:objectValueForTableColumn:row:] (self=0x10014ab00, _cmd=0x7fff87fa850c, tv=0x100139930, tableColumn=0x100139ba0, row=0) at /Users/davemayer/Implementation/Cocoa Programming for Mac OS X/SpeakLine/SpeakLine/SpeakLineAppDelegate.m:85
#2 0x00007fff877e711b in -[NSTableView _dataSourceValueForColumn:row:] ()
#3 0x00007fff877e6b9b in -[NSTableView preparedCellAtColumn:row:] ()
#4 0x00007fff877f7ca5 in -[NSTableView _drawContentsAtRow:column:withCellFrame:] ()
#5 0x00007fff877f610c in -[NSTableView drawRow:clipRect:] ()
#6 0x00007fff877f58e9 in -[NSTableView drawRowIndexes:clipRect:] ()
#7 0x00007fff877f3a0b in -[NSTableView drawRect:] ()
#8 0x00007fff8775aabe in -[NSView _drawRect:clip:] ()
#9 0x00007fff877881eb in -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] ()
#10 0x00007fff87788617 in -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] ()
#11 0x00007fff87758099 in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] ()
#12 0x00007fff8775934e in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] ()
#13 0x00007fff8775934e in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] ()
#14 0x00007fff8775934e in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] ()
#15 0x00007fff87757593 in -[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] ()
#16 0x00007fff877529af in -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] ()
#17 0x00007fff8774b429 in -[NSView displayIfNeeded] ()
#18 0x00007fff8774ab69 in _handleWindowNeedsDisplayOrLayoutOrUpdateConstraints ()
#19 0x00007fff8d2cdf64 in __NSFireTimer ()
#20 0x00007fff838cdc24 in CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION ()
#21 0x00007fff838cd776 in __CFRunLoopDoTimer ()
#22 0x00007fff838ae001 in __CFRunLoopRun ()
#23 0x00007fff838ad676 in CFRunLoopRunSpecific ()
#24 0x00007fff85b8331f in RunCurrentEventLoopInMode ()
#25 0x00007fff85b8a5c9 in ReceiveNextEventCommon ()
#26 0x00007fff85b8a456 in BlockUntilNextEventMatchingListInMode ()
#27 0x00007fff8770ef5d in _DPSNextEvent ()
#28 0x00007fff8770e861 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#29 0x00007fff8770b19d in -[NSApplication run] ()
#30 0x00007fff87989b88 in NSApplicationMain ()
#31 0x0000000100001c52 in main (argc=3, argv=0x7fff5fbff8d0) at /Users/davemayer/Implementation/Cocoa Programming for Mac OS X/SpeakLine/SpeakLine/main.m:13


#9

I should clarify something. My “Bad Access” problem started with the SpeakLine project mods in chapter 6, and that is what my messages/trace above is referring to (not RaiseMan). After I had the SpeakLine problem a while back, I put it aside and moved ahead in the book, until I encountered the same sort of problem in RaiseMan, where I found this discussion, and decided to post my comments here. However, after looking more carefully at the errata for chapter 6 Helper Objects, I found the solution in the discussion on [Program received signal: “EXC_BAD_ACCESS”]. Apparently I simply had to add “retain” to the statement: _voices = [[NSSpeechSynthesizer availableVoices] retain];

Indeed, I had ARC turned off, and the “retain” addition fixed it. But since ARC should be enabled from now on (I assume), I went ahead and enabled ARC (Edit>Refactor>Convert…), and it cleaned it all up. I will apply what I’ve learned here to future projects, such as RaiseMan.

Thank you.


#10

I am also working through the book with an outdated XCode because I haven’t updated to Lion…

Like davo123 I also fixed SpeakLine by retaining (and releasing) the NSSpeechSynthesizer object.

[code]- (id)init {
self = [super init];
if (self) {
_speechSynth = [[NSSpeechSynthesizer alloc] initWithVoice:nil];
[_speechSynth setDelegate:self];
_voices = [[NSSpeechSynthesizer availableVoices] retain];
// PD was getting released after first access
}
return self;
}

  • (void)dealloc {
    [_voices release];
    [super dealloc];
    }
    [/code]

For this app, to get it to run as of p139 - the basic create and edit - I needed to retain/release in these places.

In Person.m:

- (id)init
{
  self = [super init];
  if (self) {
    employees = [[[NSMutableArray alloc] init] retain]; // PD added retain
  }
  return self;
}

- (void)dealloc {
  [employees release]; // PD added release
  [super dealloc];
}

- (void) setEmployees:(NSMutableArray *)a {
  if (a == employees) // point to same object, no action
    return;
  [employees release];          // PD added release
  employees = [a retain];       // PD added retain
}

In RMDocument.m:

- (id)init
{
  self = [super init];
  if (self) {
    employees = [[[NSMutableArray alloc] init] retain]; // PD added retain
  }
  return self;
}

- (void)dealloc {
  [employees release]; // PD added release
  [super dealloc];
}

- (void) setEmployees:(NSMutableArray *)a {
  if (a == employees) // point to same object, no action
    return;
  [employees release];          // PD added release
  employees = [a retain];       // PD added retain
}

Now the application appears to be running smoothly, though I have not done any further checking. Your results may vary.


#11

To get this project to work without Automatic Reference Counting (ARC), I believe you can get away with changing only the setEmpoyees method. Paraphrasing PeeDee here:

-(void)setEmployees:(NSMutableArray *)a
{
  if (a == employees) {
    return;
  }
  
  [a retain];             // retain the new array
  [employees release];    // release the old one
  employees = a;          // point employees at the new array
}

This line:

doesn’t actually need a retain statement. The call to alloc does a retain for you. Basically, whenever you use alloc, copy, or new, the object is retained.

Then, to be a good memory management citizen, implement dealloc methods in both the Person class (where you release personName, then call [super dealloc]) and to RMDocument (where you release employees and then call [super dealloc]).