Theis Egeberg
Theis Egeberg

Reputation: 2576

iOS application gets EXC_BAD_ACCESS at same memory address but with different causes

I am building an iOS application. It's using a C++ library which runs alongside (crowd simulation lib, which determines positions of many agents) a cocos2d game.

After I added some more animations and extra bells and whistles the app crashes after about 6-30 seconds, with errors like: tiny_malloc_from_free_list tiny_free_list_remove_ptr

The thing is, it ALWAYS happens at the same memory address 0x1000. But I can replicate the error on two different devices exactly, so it's not the memory itself which is bad.

I'm not expecting a complete answer, but some pointers to where I should start looking would be very nice :) thank you!

EDIT: I removed the c++ lib completely, but the error still persists. I will update once I have gotten closer.

EDIT: The problem was in the Cocos2d v. 2 display stats adding and removing pointers. Thank you for all of your help! one of the texture enum vals was 1<<12 and was used as a pointer... I stopped using the display stats. :) thank you all!

Upvotes: 0

Views: 716

Answers (2)

nielsbot
nielsbot

Reputation: 16032

Assuming your backtrace doesn't immediately show the problem...

Sounds like it could be a deference of a nil "object", where the code is attempting to reference *(p + 0x1000). Note that 0x1000 is probably the VM page size.

In situations like this I turn on zombies and guard malloc to see if I can catch the problem as it happens.

Upvotes: 1

Chris Trahey
Chris Trahey

Reputation: 18290

With an address like that, I would suspect int-to-pointer conversion somewhere. What is that, 4096? I might search the library for a constant with that value (perhaps achieved via bit-shifting 1<<12), and see if I could find code using that constant in strange ways.

Upvotes: 1

Related Questions