Broken malloc on compile (mac)...

BlitzMax Forums/BlitzMax Programming/Broken malloc on compile (mac)...

ima747(Posted 2011) [#1]
I haven't use bmax for a while, but when I tried to compile an old project today it immediately crashes (before I can get it to run a print command) and throws

MyProjectName(13403,0xa03e9540) malloc: *** mmap(size=1791782912) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
MyProjectName(13403,0xa03e9540) malloc: *** mmap(size=1791782912) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug


Sometimes it will however run... until I try to enter full screen mode. then it crashes in a call to allocMem according to the crash report.

I haven't touched the project or bmax to the best of my recolection since the last time I compiled and ran it. I've gone through a couple xcode beta installs next to my release install at the same time so I suspect there's something going on in there...

Any tips as to where I should look? I've tried rebuilding my modules in the hopes something was dirty in there but no luck. The project require multithreading so unfortunately I can't turn threaded build off.

This is under snow leopard with Xcode 3.2.6 installed and XCode 4 current beta installed on another drive (though some of the build tools get put on the boot drive anyway...).

update: the old builds still run fine, so it's definitely something from the compile process not the code...

Last edited 2011


ima747(Posted 2011) [#2]
More poking:

The times it does execute (then crash when going full screen) it looks like it's using almost 1gb of real ram AND almost 1gb of virtual memory...

The old compile (same source code, just compiled months ago when things work...) uses 21mb of real mem and 77mb or virtual when started to the same point...

So I suspect it's running out of memory (being a 32 bit application) dieing which is what the errors indicate... but why does it all of a sudden use 2gb of memory from the same code? again I'm looking at xcode installs as the cause as that's the only thing I think that has changed... but it's very very weird...


ima747(Posted 2011) [#3]
more poking... the following code crashes as well...

SuperStrict

Print "ok!"


however this does not...
SuperStrict

Framework MaxGui.Drivers

Print "ok!"


I've rebuilt my modules but it would appear something in a standard module (other than maxgui.drivers...) is blowing up... again, I haven't updated any modules since the last time it worked...


Jesse(Posted 2011) [#4]
Do a fresh install of BMax.
you are not using quick build, are you?

Last edited 2011


ima747(Posted 2011) [#5]
I've been rebuilding everything in the hopes that it would clear a gremlin.

I've tried replacing the standard modules from the newest release in the hope it would fix it but no dice. Currently building all module under a fresh download but my hopes are not high since none of this had changed since last time anyway... suspecting xcode4 beta side install still, not sure what to do about it since I need both installs and they work for xcode things...

rebuild completed. same results.

Last edited 2011


Jesse(Posted 2011) [#6]
did you transfer your program build folder from windows to mac?
I had a problem where I couldn't run a program because it was reusing some of the windows build files.
I had to remove all of the none source files first.

Last edited 2011


ima747(Posted 2011) [#7]
Nope. It hasn't moved in almost a year and even then it was Mac to Mac along with the bmax install. I haven't touched or moved anything bmax related since the last time I ran it successfully besides Xcode.


Jesse(Posted 2011) [#8]
wan't share the executable see if it runs on my Mac?


ima747(Posted 2011) [#9]
Thanks, but I just tried it on the other mac and it crashes. And tried the old compile on the other mac and it works. So results are the same on a different computer. Definitely an artifact of the compile process... going to try provoking modules and see if that gets me anywhere... really don't want to overhaul 2 xcode installs...


ima747(Posted 2011) [#10]
Does anyone know where bbArrayNew() gets called from? It's in blitz_array.c in blitz.mod however I can't find any references to where it could get called from? I see references to bbArrayNew1D() and bbArrayNewEx() in other files, but never bbArrayNew() which is a problem because it's part of the flow that leads to the crashes I'm seeing but I can't trace it back up because I don't know how it gets to bbArrayNew() in the first place...


ima747(Posted 2011) [#11]
I tried bmax on my old computer which hasn't had xcode or anything bmax related updated since I last used it atleast 8 months ago and it has the same issue which leads me to believe it's an issue with a bmax module and an OS update...

The only thing that has changed on that system since it worked, system wide, is the OS has been updated with software update regularly.

something as simple as
SuperStrict

Print "ok!"

While True
	
Wend


will either crash on launch from over allocation, or use 2+ gb of memory regularly (on the verge of crashing basically).

If I put a framework call in it will behave as usual (about 4mb of memory if I framework MaxGui.Drivers for example).

I downloaded the most recent release for bmax and I get the same results. This is a clean download of the newest release. I had to compile the modules to make it work (they claimed their architecture didn't match...) but with no other modules, no modifications, no changes at all from stock it still goes screwy with a basic 4 line program.

Since no one else is reporting this issue I don't think it's bmax. Since it happens to me on 2 computers with different XCode installs I don't think it's XCode. That leaves recent OS updates to snow leopard as the only consistent point I can put my finger on... This theory is complicated by the fact that something previously compiled still runs without issue however so it's specifically compiling after updating the OS which seems very unlikely...

Based on the crash reports for
SuperStrict

Print "ok!"

While True
	
Wend




My suspicion is that something in the startup process of some very basic module allocates something that's going crazy... but as I noted above, I can't find anything that actually uses bbArrayNew() so I have no idea what/where it might be...

Last edited 2011

Last edited 2011


ima747(Posted 2011) [#12]
Rebuilt a new boot disk with Lion.

Using Xcode beta for lion and my old blitzmax folder (mods etc.) it runs (with lion issues but that's a totally separate topic) without memory issues. Had to use the IDE from the 1.43b lion build, but still using the old pub and brl mod folders.

Using the 1.43b pub and brl mods, and the rebuild modules the memory issue comes back... however using the 1.43b package there is no memory issue... this is doubly confusing.

side bar: I had to fix some issues in bmk_util.bmx. references to "-4.2" should be " -4.2" otherwise it throws an error when attempting to link since it tries to executer "g++-4.2" which isn't a command, it should be "g++ -4.2" with "-4.2" as an arg... not sure why no one else has posted this since it makes the 1.43b package un-usable unless you use an older bmk, or have one handy to build with...


ima747(Posted 2011) [#13]
Got it working! not 100% sure what was wrong but I replaced the pub and brl from my old install with the ones from the 1.43b lion install. I also had to replace the bmk with the "fixed" bmk (with the "-4.2" corrections noted above). I had tried and older bmk, as well as been using brucy's modified bmk which the newest lion compatible version seems to throw the same g++ error so I suspect it needs to be tweaked as well...

Yay back in business.