Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dancks

macrumors regular
Original poster
Nov 8, 2009
100
0
So I'm debugging a C++ program I wrote using game library allegro. I fixed a problem with returning a pointer from a function, recompiled, retested, and I got the following from GDB:
Code:
****** malloc error repeated 1000 times ******
p9rev6(6901,0xb00a1000) malloc: *** error for object 0xfa910b88: Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
p9rev6(6901,0xb00a1000) malloc: *** error for object 0x3376a0: double free
*** set a breakpoint in malloc_error_break to debug

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0xc0000023
0x91c79688 in objc_msgSend ()
(gdb) backtrace
#0  0x91c79688 in objc_msgSend ()
#1  0x96f5b38a in CFRelease ()
#2  0x90b8d866 in ReleaseEvent ()
#3  0x910d280c in -[NSEvent dealloc] ()
#4  0x95ff444f in NSPopAutoreleasePool ()
#5  0x0020e929 in osx_event_handler ()
Cannot access memory at address 0x2ff
(gdb) x/i $pc
0x91c79688 <objc_msgSend+24>:	mov    0x20(%edx),%edi
(gdb) p/x $edx
$1 = 0xc0000003
(gdb) p/x $edi
$2 = 0x3473f0
(gdb)

ok so its a segmentation fault, so I should be looking for an out of bounds array call or write-to?
 
I'd guess you returned the value 35 cast to some sort of pointer, then tried to dereference. Never cast another primitive to a pointer. You can get a pointer with & or get a pointer to some new memory with malloc.

-Lee
 
I would have guessed that that the NSAutoReleasePool tried to release an object that has already been dealloc'd.

Hence the stack trace, and double free.

I see the 35 (0x23) but there is also a 0xc0 in the highest order byte of that address. So I'm not so sure about dereferencing an ints value...
 
I would have guessed that that the NSAutoReleasePool tried to release an object that has already been dealloc'd.

Hence the stack trace, and double free.

I see the 35 (0x23) but there is also a 0xc0 in the highest order byte of that address. So I'm not so sure about dereferencing an ints value...

Oops. The tiny text on my phone (with no retina display) made it look like all 0s then 23.

-Lee
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.