Re: Malloc Error: pointer being freed was not allocated
Re: Malloc Error: pointer being freed was not allocated
- Subject: Re: Malloc Error: pointer being freed was not allocated
- From: Richard Somers <email@hidden>
- Date: Sat, 08 Sep 2012 07:44:00 -0600
On Sep 7, 2012, at 3:55 PM, Jens Alfke wrote:
> On Sep 7, 2012, at 12:01 PM, Richard Somers <email@hidden> wrote:
>
>> MyApp(469,0x1009fbcc0) malloc: *** error for object 0x12f6b19a0: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug
>> Following the instructions and adding a symbolic break point (malloc_error_break) results in nothing different. The application still halts at the same location with the same error.
>
> From the stack it looks like the environment variable MallocErrorAbort is already set, so you’ve already stopped at the point of the error.
>
>> I have searched through every stack frame and can find no reference to the pointer in question 0x12f6b19a0. You would think that this pointer would be located somewhere in one of the stack frames.
>
> The only stack frame that would necessarily be referring to it is #3, gfxReleaseSharedState — I don’t know if that’s your code or not. That function has called free( ) on that pointer.
>
>> A po or p on the pointer in the debug console produces nothing useful.
>
> It isn't an Objective-C object, because gfxReleaseSharedState is directly calling free() on it.
>
> I don’t have much more advice, because it looks like the code on the stack is related to OpenGL, which I don’t know anything about. It’s possible you’ve got the refcounting wrong for something GL-related, so that the ‘shared state’ referred to has already been freed.
>
>> The stack looks like this:
>>
>> #0 0x00000001008700b6 in __kill ()
>> #1 0x00000001009109f6 in abort ()
>> #2 0x0000000100828195 in free ()
>> #3 0x00000001064c01b3 in gfxReleaseSharedState ()
>> #4 0x000000012cc3d91f in gliDestroyContext ()
>> #5 0x0000000100166de4 in CGLReleaseContext ()
>> #6 0x0000000100169faa in CGLDestroyContext ()
>> #7 0x000000010001468d in -[RSTriadLayer releaseCGLContext:] at RSTriadLayer.m:302
Jens, thanks for the help.
I found the pointer. It appears in frame #2 free () and higher frames in one of the general purpose registers. One would think that the pointer would show up in frame #3 gfxReleaseSharedState () which calls free () but it does not. My code is frame #7 and #10 and everything else is from the frameworks.
Yes, it appears this is some sort of OpenGL related memory management issue.
--Richard
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden