iMiniB3D EXC_BAD_ACCESS on exit.

BlitzMax Forums/MiniB3D Module/iMiniB3D EXC_BAD_ACCESS on exit.

Sledge(Posted 2010) [#1]
As per thread topic, pressing the home button when "building and going" from XCode causes entity.mm to get flagged up. Looks fairly innocuous on the surface, but it could be an AppStore approval breaker in the making.

(EDIT: Oh and I should really 'fess up to the fact that both my iPod OS and SDK are an iteration behind so feel free to encourage me to (finally) install Snow Leopard by shouting "Oh no it doesn't!")


ima747(Posted 2010) [#2]
I haven't used iMiniB3D in quite a bit at this point, but I recall getting that. I believe I got it to go away my releasing everything I had created, and I think there may have been a handling issue with either meshes or textures that I had to track down... maybe one of my old threads can be of a little more help.


simonh(Posted 2010) [#3]
I'll release 0.4 very soon, so hopefully that will fix it.


Beaker(Posted 2010) [#4]
I did find updating to Snow Leopard and/or updating the SDK etc helped sort a few issues I was having.


Sledge(Posted 2010) [#5]
@simonh Cheers. In the meantime I'm just manually freeing everything in Game:End() rather than using Global::ClearWorld(). Out of interest, should I be freeing a list that is a member of Game, rather than just deleting all of its (the list's) objects after freeing their members? (I'm kinda picking up C++ primarily from the iMiniB3D examples so I'll probably have a few dumb questions like this.)

@ima747 Thanks -- just rummaging through your previous posts.

@Beaker Yeah I really need to set some time aside to update everything. Typically, the external drive I would normally use for backup during such a process has started reporting errors this weekend! :(


ima747(Posted 2010) [#6]
Best of luck with the rummage Sledge I tend to wander :0)

regarding updating specifically for iphone development it tends to be a good idea to keep everything as new and shinny as possible, apple is much quicker to depreciate things in the iphone SDK than for mac. I recall spending 2 weeks getting some listboxes to work just right and then they overhauled the events quite a bit so I either had to start over or stick with an old OS target, which was fine since I wanted legacy support, but when it finally came time to drop the old OS's for some new features I had to do a good chunk of re-working...

@simonh I'm drooling already...


Robert Cummings(Posted 2010) [#7]
Good work si, looking forwards to 0.4. Just a heads up to appstore people: please post back on these forums if you release a game with iMiniB3D, I am sure si will be pleased as heck to see his little engine in action in other games...

Also one other thing, if you're targetting iPad compatibility (>3.2) you need to ensure your orientation flips. This is a callback in your delegate. The easiest way to deal with this is just rotating the camera, but in your touch handler you will want to flip the touch x,y depending.

Also, you need to ensure that its flipped dynamically. That is, you can't guarantee its running on 320x480. It could be ipad dimensions, so query the system.


Sledge(Posted 2010) [#8]
@ima747 Yeah I just updated and re-tested to make sure it wasn't being behind that was the problem. Fortunately (for my dignity I mean) Global::ClearWorld() still causes the EXC_BAD_ACCESS flip-out. It's quite an intriguing error:
Current language:  auto; currently objective-c++
Program received signal:  “EXC_BAD_ACCESS”.
Warning: the current language does not match this frame.
kill
quit
It flags up different iMiniB3D source files based on what has or hasn't been manually freed.

@Rob Sigh, another set of docs to digest -- thanks iPad! :D


ima747(Posted 2010) [#9]
Hmm, I'm not seeing any problems with ClearWorld() at the moment. Can you punch of a test that causes it?

What is your build target? (debug/release, simulator/device, iphone/ipad)

Are you sure you're not over freeing things?


Sledge(Posted 2010) [#10]
Hmm, I'm not seeing any problems with ClearWorld() at the moment. Can you punch of a test that causes it?
All the examples that use it!


What is your build target?
It's now Device - 3.2 | Release. Incidentally, how do I get the iPad simulator to sod off when building for the simulator? Since updating, XCode has arbitrarily decided that I want to be an iPad developer, which is a bit presumptuous of it!

Are you sure you're not over freeing things?
Nah, I just commented out the manual freeing of things and it made the same complaint (although it's flagging up stl_iterator_base_funcs.h now!)

Note that I'm causing this behaviour by pressing the home button while the build is running on an actual device. It doesn't complain when you press the virtual home button in the simulator (bearing in mind that it currently insists on being an iPad instead of an iPhone (grrrrr!), for what the difference is worth).


Robert Cummings(Posted 2010) [#11]
It's now Device - 3.2 | Release. Incidentally, how do I get the iPad simulator to sod off when building for the simulator? Since updating, XCode has arbitrarily decided that I want to be an iPad developer, which is a bit presumptuous of it!


You can't/won't get 3.2 for the iPhone. 3.2 is iPad only, so build for 3.1x.


Sledge(Posted 2010) [#12]
Ah, cheers. It merrily building for the device threw me there.


ima747(Posted 2010) [#13]
yea, building under 3.2 gets you iphone, 3.2 gets you ipad in simulator. A real device will just fail on calls that are not implemented on it's revision (so if you build a 3.1 and deploy on 2.0 the new api calls on from 3.1 if you make any will fail, which is why you're supposed to test for apis before using them if you're targeting mixed versions or mixed devices that might not have things, such as camera on a touch or ipad...). Though in the simulator the device toggle in the menu REALLY should lock it to that device for testing imo...

I'll do some more poking but I wasn't seeing any errors back on device. will report back after I give it another poke.


ima747(Posted 2010) [#14]
Finally got to give it another poke and I'm getting the exec error as well when pressing home on a device in either release or debug mode.

Seems to come from an SDK header
Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/include/c++/4.2.1/bits/stl_list.h
This is coming from FreeEntity, specifically for me from freeing a pivot, under Global::ClearWorld. It happens while iterating child entities, on child_list.size()

[update]
Seems as though I am clearing the world in game->end() and then applicationWillTerminate is also clearing the world after it runs game end... Removing either of the clearworlds fixes the problem. I think multiple clears shouldn't cause issue, but it's easy to work around. Either clear yourself, or let the appdelegate handle it. Basically it's a double release.
[/update]

Side note: if you're targeting universal this might be helpful
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
	viewCamera->CameraViewport(0, 0, 320, 480);
} else {
	viewCamera->CameraViewport(0, 0, 768, 1024);
}



jhocking(Posted 2010) [#15]
huh, I just assumed you're not supposed to quit while testing by hitting the home button, it didn't even occur to me that this is a problem to fix. I've just been using Stop in the Run menu, now I'm worried that this has been causing problems on my iPhone.


ima747(Posted 2010) [#16]
It's not really that big a deal in the real world, just very impolite to the memory... When you exit the memory gets wiped for your app anyway. Additionally it only happens if you manually clearworld before exiting (being too polite) which then sets up the clearworld in the appterminate event to cause some uglyness. Hopefully simon can clean up clearworld so running it more than is needed doesn't cause this glitch (I assume something is just not getting nulled out once it's freed so the next pass still sees a value even though it's dead). But until then just don't clearworld manually at the end and you get no problem.


Sledge(Posted 2010) [#17]
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
	viewCamera->CameraViewport(0, 0, 320, 480);
} else {
	viewCamera->CameraViewport(0, 0, 768, 1024);
}

Neat!

Good investigative work there, too.

I'm worried that this has been causing problems on my iPhone.
When you exit the memory gets wiped for your app anyway.
I'm not convinced by how good the OS is at this: I've had apps that failed to start for seemingly no reason, which returned to normal operation after a hard reset. Nothing definitive in that, but it fits with the notion of a dwindling pool of available mem.


ima747(Posted 2010) [#18]
well the bad access is caused by a double release, so there may be a little leftover but since it's over clearing (rather than under) there shouldn't be much left, and the app memory space should be opened up after it's released... course no guarantee which is why it's nice to get a clean exit, but I'm not too concerned for testing atleast. And just make sure you don't over clearworld and it goes away so no issue... and again hopefully simon can work it out so over running clearworld doesn't cause the fault at all.


Sledge(Posted 2010) [#19]
Oh I'm not trying to suggest that running iMiniB3D apps might be causing available mem to dwindle over time, I'm suggesting that running apps might be causing available mem to dwindle over time!


ima747(Posted 2010) [#20]
Ah, I C, and agree very much. if you still have a first gen iphone around give the poor thing a night in the off position some time, it'll wake refreshed and much perkier... for a short while :0) there is also the mysterious performance decay on iphones as well which is a secondary but related issue... but i digress from the thread. And now back to my wads of code.