Hard Light Productions Forums

Hosted Projects - FS2 Required => Blue Planet => Topic started by: Crybertrance on January 09, 2013, 05:21:32 am

Title: Malloc Failed?
Post by: Crybertrance on January 09, 2013, 05:21:32 am
Okay, now this is strange; I started playing Tenebra earlier today, finished the dreamscape and quit halfway through the first combat mission (gameplay was going well, good fps, perfect). But now, whenever I stat FSOpen and select my "Blue Planet 2"(This is a new pilot I created just before playing Tenebra) pilot, I get this:

Code: [Select]
Malloc Failed!

ntdll.dll! ZwWaitForSingleObject + 21 bytes
kernel32.dll! WaitForSingleObjectEx + 67 bytes
kernel32.dll! WaitForSingleObject + 18 bytes
fs2_open_3_6_17_SSE2_BP.exe! <no symbol>
fs2_open_3_6_17_SSE2_BP.exe! <no symbol>
fs2_open_3_6_17_SSE2_BP.exe! <no symbol>
fs2_open_3_6_17_SSE2_BP.exe! <no symbol>
fs2_open_3_6_17_SSE2_BP.exe! <no symbol>
fs2_open_3_6_17_SSE2_BP.exe! <no symbol>
fs2_open_3_6_17_SSE2_BP.exe! <no symbol>
fs2_open_3_6_17_SSE2_BP.exe! <no symbol>

Note that I also got this error one or twice before at random times while playing Tenebra.
Creating a new pilot gets my to the Mainhall, but selecting the WiH 2 campaign from the Campaign Room get me the error too.

Log: http://pastebin.com/yXaSve3d
Title: Re: Malloc Failed?
Post by: niffiwan on January 09, 2013, 05:35:07 am
I think you've hit this bug (http://scp.indiegames.us/mantis/view.php?id=2503).  Unless you like interpreting the source code & messing with hex editors, it's new pilot time :(

Would you be able to zip up your pilot files (.plr & .csg) and attach them to the mantis issue?  Or otherwise post them in this thread?  That may help us track down what's causing these issues.
Title: Re: Malloc Failed?
Post by: Crybertrance on January 09, 2013, 05:43:49 am
Hmm...renaming the "players" folder and creating a new pilot (couldnt even delete all pilots through the pilot selector; they just kept re-appearing the next time I ran FSO) got me able to start WiH 2 again.

Btw, do you want all my pilot files? or just the "Blue Planet" and "Blue Planet 2" ones (which are the Ant8 code generated ones)?

Edit: I also might mention this; since it might relate to the new pilot code. When I created the new pilot for BP2 earlier, I noticed that through the tech room all the missions in WiH 2 were unlocked. But after my current renaming of the players folder, and then creating a new pilot...everything is locked as it should be.
Title: Re: Malloc Failed?
Post by: Solatar on January 09, 2013, 11:56:29 am
I caused this bug on my system by switching builds and mods back and forth between 3.6.17 BP and the 3.6.16 RC 1.  I switched from the new BP stuff, had performance issues, tried running the Port (less intensive) under the same BP build to determine if it was the build or BP data, and that ruined the pilot, just like the install post said it would :p.  When I went back to BP, I got in-game warnings (several in a row) about not being able to find the campaign file, campaign progress file, etc. Malloc error happened sometime after (I think after game restart).

Deleting the pilots in-game wasn't enough to make a clean pilot, I also had to delete the campaign progress files in players/single/inferno/.  If I didn't, then a new player with the same name as an old one would inherit all the problems (and campaign progress).

I'm not 100% sure what's caused it (I no can code), but I've avoided seeing the error again so far by keeping a single pilot only used for this BP campaign, and not evening switching campaigns in the campaign room.
Title: Re: Malloc Failed?
Post by: niffiwan on January 09, 2013, 03:57:23 pm
Hmm...renaming the "players" folder and creating a new pilot (couldnt even delete all pilots through the pilot selector; they just kept re-appearing the next time I ran FSO) got me able to start WiH 2 again.

Btw, do you want all my pilot files? or just the "Blue Planet" and "Blue Planet 2" ones (which are the Ant8 code generated ones)?

Deleting the pilots in-game wasn't enough to make a clean pilot, I also had to delete the campaign progress files in players/single/inferno/.  If I didn't, then a new player with the same name as an old one would inherit all the problems (and campaign progress).

Regarding the pilots reappearing after being deleted in FSO, that's because ant8 converts any inferno pilots it finds, except where an ant8 pilot of the same name exists.  When you delete the ant8 pilot, it gets converted again next time you start FSO.  To stop this happening, you need to rename/delete your inferno pilot files  (We also need to handle this better in the code...)

As for the pilots I'm interested in, just the "Blue Planet" and "Blue Planet 2" ones (i.e. ant8).  Thanks
Title: Re: Malloc Failed?
Post by: Dark Hunter on January 09, 2013, 08:13:40 pm
Odd. I just hit this bug upon trying to load up a pilot file that had finished the campaign. I didn't have any problems before this. I can attach my pilot file if it'll help.

I think you've hit this bug (http://scp.indiegames.us/mantis/view.php?id=2503).  Unless you like interpreting the source code & messing with hex editors, it's new pilot time :(

Just out of curiosity, what do you do if you DO have hex editors and code knowledge?
Title: Re: Malloc Failed?
Post by: niffiwan on January 09, 2013, 08:43:37 pm
Firstly, attaching the pilot file should help, as I'm still trying to work out how to reproduce the issue.  I think one of the complexities is that the problem occurs at time X, but it doesn't manifest until time Y which can be a while after time X, thus making it hard to figure out what you were doing when the problem actually occurred. 

Secondly, on repairing pilot files...

1) You need to find the red-alert section in the relevant .csg file.  This is easy with a busted file, since it'll be 99%+ comprised of the red-alert section :lol:  If you open the .csg in a hex editor you'll see shipnames repeated over and over, perhaps millions of times.  This is data from the last red alert mission that you played.

2) You remove all the data from the red-alert section EXCEPT for one "set" of red alert data.  i.e. each ship & its data should only be listed once.  Since I'm on Linux the tools I used for this were "head -c / tail -c / cat" to remove the bad data and patch the file back together, with a hex editor (ghex2) to provide me with the relevant byte offsets in the file. 

3) You need to find the integer value in the .csg which records the number of red alert entries and modify it so that it matches with the number of ships stored in the red alert section.  Remember that integers on little-endian x86 CPUs are stored LSB (least significant byte) first, so you need to reverse the order of the 4 bytes that make up the integer when you insert your new value (e.g hex 01 00 00 00 for "1" instead of hex 00 00 00 01).  This is the bit that you really need to read the code for, to work out what order FSO expects all the .csg data to be in and therefore be able to find the correct 4 byte section of the file to modify.

Honestly, it's fiddly and very prone to error.  It's probably easier to create a new pilot file & replay your current campaign :)
(unless you're a masochist like me who wanted to learn how the pilot file worked :nervous:)

edit: what the hey, here's the part of the code you need to start reading: function pilotfile::save_savefile() in code/pilotfile/csg.cpp.

edit2: if you don't want to hex-edit your pilot, you've got some other options
1) start a new pilot and use CTRL-SHIFT-S in the techroom to unlock all the campaign missions, then play them one by one from here (note: you won't get medals, and campaign persistent variables may not work)
2) start a new pilot, and create a custom .fc2 (i.e. campaign file) that starts from the mission where you encountered the problem
3) start a new pilot, and play the entire campaign again

In all cases, you should also get a more recent FSO executable, as this bug is now fixed in the recent BP builds, and the recent 3.6.19 nightlies
Title: Re: Malloc Failed?
Post by: Crybertrance on January 10, 2013, 12:22:55 am
Ah, the stuff you coders go through!  :(

I think I'll give the stuff you mentioned above a try though, most probably won't fix anything, just for the lulz (I am learning to code anyways)

Anyways, here are the files you mentioned niffiwan...

http://www.mediafire.com/?7im9muhj1pa189b (http://www.mediafire.com/?7im9muhj1pa189b) (since HLP wont let me attach)
Title: Re: Malloc Failed?
Post by: Meneldil on January 10, 2013, 07:00:04 am
@Niffiwan: Wow man, thanks! Saved me from a replay in the middle of  finals :)
The integer was right in front of that crazy red alert stuff, so that wasn't a problem.

(Just for the record, 1 327 104 mentions of GTC Duke. And the problem didn't stop, just started anew, but unless I screwed something up this should work fine until I finish the campaign.)
Title: Re: Malloc Failed?
Post by: niffiwan on January 10, 2013, 04:23:49 pm
I'm glad it helped out :)
Title: Re: Malloc Failed?
Post by: crizza on January 17, 2013, 10:00:10 am
Since I have the bug...I don't get what to do and am not that amused to replay the whole campaign again...
Title: Re: Malloc Failed?
Post by: Crybertrance on January 17, 2013, 11:02:33 am
Since I have the bug...I don't get what to do and am not that amused to replay the whole campaign again...

You'd have to rename your player folder in "FS root/data" and create a new player. Needless to say, you have to replay the campaign.

If you know coding, or are feeling adventurous, you can try the steps Niffiwan stated 4 posts above.
Title: Re: Malloc Failed?
Post by: crizza on January 17, 2013, 11:32:50 am
Wtf?!
How can this happen in the first place? Is that a mistake I made while installing or is it a code related issue?
And I just finished the campaign, great -.-
Title: Re: Malloc Failed?
Post by: Crybertrance on January 17, 2013, 11:47:01 am
Wtf?!
How can this happen in the first place? Is that a mistake I made while installing or is it a code related issue?
And I just finished the campaign, great -.-

Its a code related issues. Antipodes 8 has a bug when dealing with Red Alert campaigns (or something?). Some weird code bug, happened to me even though I created a new pilot for Act 3 specially! That too, just in the second mission (lucky me).
Title: Re: Malloc Failed?
Post by: crizza on January 17, 2013, 12:34:18 pm
I reinstalled everything for the rerelease of AoA and created a Pilot, then I installed the Tenebra stuff...*sigh*
Title: Re: Malloc Failed?
Post by: Killer Whale on January 18, 2013, 11:56:08 pm
Yay! I get to replay all of act 1 again, mere days after finishing it!

[attachment deleted by a basterd]
Title: Re: Malloc Failed?
Post by: niffiwan on January 19, 2013, 12:05:51 am
You might want to hold off replaying act1 for now as the problem is triggered by any red alert mission.  I've got a fix ready, but you'll need a new executable (and SVN is down at the moment, so it might slow things down).
Title: Re: Malloc Failed?
Post by: Crybertrance on January 19, 2013, 12:00:40 pm
You might want to hold off replaying act1 for now as the problem is triggered by any red alert mission.  I've got a fix ready, but you'll need a new executable (and SVN is down at the moment, so it might slow things down).

But, iirc Act 1&2 don't contain Red Alert missions. The only Red-Alert mission was in AoA.
Title: Re: Malloc Failed?
Post by: Dragon on January 19, 2013, 12:33:02 pm
Indeed. The lesson learned with AoA was that Red Alert, especially chained into 3+ mission sequences, does not work reliably. Thus it should be absent from WiH.
Title: Re: Malloc Failed?
Post by: niffiwan on January 20, 2013, 03:57:52 am
You might want to hold off replaying act1 for now as the problem is triggered by any red alert mission.  I've got a fix ready, but you'll need a new executable (and SVN is down at the moment, so it might slow things down).

But, iirc Act 1&2 don't contain Red Alert missions. The only Red-Alert mission was in AoA.

derp - yes, you are quite right, I was thinking of AoA...  :nervous:

edit: and I've just committed the fix to SVN...
Title: Re: Malloc Failed?
Post by: Bryan See on October 25, 2013, 11:42:51 am
I've experienced it before, on my latest BP build, based on revision 9960, while testing on ships (taken from Diaspora, BP and many others) for my forthcoming mod called FreeSpace: Reunited, namely the mission in a Cylon perspective (http://www.hard-light.net/forums/index.php?topic=83139.0). Loading any mission get me this error, regardless of creating a new pilot.

Code: [Select]
Malloc Failed!

ntdll.dll! ZwWaitForSingleObject + 21 bytes
kernel32.dll! WaitForSingleObjectEx + 67 bytes
kernel32.dll! WaitForSingleObject + 18 bytes
fs2_open_3_7_1_SSE2_BP.exe! <no symbol>
fs2_open_3_7_1_SSE2_BP.exe! <no symbol>
fs2_open_3_7_1_SSE2_BP.exe! <no symbol>
fs2_open_3_7_1_SSE2_BP.exe! <no symbol>

I believe others may get this same error as I did. And here's my attachment containing the pilot files to help track down this issue. Thanks.

[attachment deleted by ninja]
Title: Re: Malloc Failed?
Post by: The E on October 25, 2013, 12:11:10 pm
Please post your fs2_open.log file.  Instructions on how to do this can be found in this post.
Title: Re: Malloc Failed?
Post by: Bryan See on October 26, 2013, 02:10:45 am
Here is my fs2_open.log file you asked.

[attachment deleted by ninja]
Title: Re: Malloc Failed?
Post by: MatthTheGeek on October 26, 2013, 02:26:03 am
Code: [Select]
  -mod fsr,fsr,MediaVPS_3612ಠ_ಠ

Look, I'm sure you think your mod is awesome, but I don't think it's awesome to the point of wanting to load it twice :p

Otherwise, I suggest you do a ctrl+f on "warning" and "depreciated" and start fixing those. The info on the debug log is there for a reason. It'll be much harder for everyone involved if you don't have a clean, warning-free modpack to begin with.

Title: Re: Malloc Failed?
Post by: Bryan See on October 26, 2013, 07:17:59 am
I've fixed most of the "warnings" and "depreciated" in the debug log, but I'm certain the mod files are not causing this (now I am free to prepare my BP build-required mod for development after two months of cleanup). I am certain that the source code (could be the BMPMAN and the paging mission file) has something to do with the causes of "Malloc Failed" error while loading bitmaps and EFFs during the last stages of mission loading. I noticed the log and in-game loading sequence may not be consistent, and this may be the cause of it.

Code: [Select]
BMPMAN: Found EFF (explode1.eff) with 43 frames at 25 fps.
BMPMAN: Found EFF (PWmuzzle.eff) with 4 frames at 30 fps.
BMPMAN: Found EFF (Gmuzzle.eff) with 5 frames at 30 fps.
BMPMAN: Found EFF (Cmuzzle.eff) with 4 frames at 30 fps.
BMPMAN: Found EFF (MuzzleFlash_Col_Art.eff) with 23 frames at 16 fps.
BMPMAN: Found EFF (MuzzleFlash_Col_CIWS.eff) with 2 frames at 40 fps.
BMPMAN: Found EFF (MuzzleFlash_Col_KEW_2.eff) with 2 frames at 20 fps.
BMPMAN: Found EFF (MuzzleFlash_Col_KEW_1.eff) with 2 frames at 40 fps.
BMPMAN: Found EFF (MuzzleFlash_Cyl_KEW_2.eff) with 2 frames at 20 fps.
BMPMAN: Found EFF (MuzzleFlash_Cyl_KEW_1.eff) with 2 frames at 40 fps.
Paging in mission messages
Stopping model page in...
...
Malloc failed!!!!!!!!!!!!!!!!!!!
ERROR: Malloc Failed!

EDIT: It works on loading missions with less than 150 objects.