|
ent_remove(my) crash?
#396146
03/03/12 13:49
03/03/12 13:49
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
OP
Expert
|
OP
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
Hello, I've been spending the last 6 months on and off on bug fixing. I've boiled it down to a few, which I cannot fix. They might both be connected with me doing something wrong with sys_malloc and sys_free commands, but I have no idea how to find this. Some of these issues I have posted before, and you offered me that I could send you the code and you would have a look at it. I did not do it at the time, because I had too many other things to finish before getting to these bugs. Does that offer still stand? 1)
posPredictDummy = NULL;
ship = NULL;
logNewMessage("loading level:",gameLog,OFF);
logNewMessage(level, gameLog, OFF);
sys_marker("ls0");
level_load(level); //loads the level which has been loaded on the server
sys_marker("ls1");
camEnt = NULL;
wait(1);
sc_shadows_sunLookAt = ent_create(NULL,nullvector,NULL); //important: if missing, shadeC will move random objects next round.
wait(3); //wait until the level is loaded
sys_marker("ls2");
if(disconnectedFromServer) return;
Here, I sometimes get a "crash in level_load 'ls0'". As I have no idea what exactly level_load does, I have no clue how to fix this. 2) The second one is a crash in ent_remove. This happens in 3 (rather unrelated) functions, seemingly at random. First example (crashes in se6):
void shieldEffectEnt()
{
var randID = random(9999);
logNewValue("shieldEffectEnt", randID, debugLog, OFF);
logNewValue("my:", my, debugLog, OFF);
sys_marker("se0");
set(my,PASSABLE);
vec_set(my.pan,vector(you.lastHitPan, you.lastHitTilt,0));
my.flags2 |= UNTOUCHABLE;
my_playsound(my,shieldHitOGG, volumeMain*volumeFX*500*soundBrightFlash);
sys_marker("se1");
my.parent = you;
//sc_ent_shieldImpact(my, getShieldEffectColor(you.shieldEffectType), 15, 1);
var timePassed = 0;
while(my != NULL && you != NULL && timePassed < 8)
{
sys_marker("se3");
timePassed += time_frame;
vec_set(my.x, you.x);
sys_marker("se4");
wait(1);
}
sys_marker("se2");
logNewValue("shieldEffectEnt", randID, debugLog, OFF);
logNewValue("my:", my, debugLog, OFF);
sys_marker("se5");
if(my)
{
sys_marker("se6");
ent_remove(my);
}
sys_marker("se8");
}
Second example of ent_remove crash (crashes in w31):
weaponArray[userID*7 + you.upgradeType - 1] = NULL;
sys_marker("w29");
if(snd_playing(lightningGunSound[userID])) snd_stop(lightningGunSound[userID]);
sys_marker("w30");
if(snd_playing(machineGunSound[userID])) snd_stop(machineGunSound[userID]);
sys_marker("w31");
if(you) ent_remove(you);
sys_marker("w32");
}
The third problem is that the debugger crashes on me with an error message "out of memory". I have 4 gigabytes of RAM (can use about 3.1 of that, since my PC is a 32 bit machine) and my game takes a max of 1, usually. This one we have talked about before, and you asked me to send you my code. P.S. I use Version 7.86.6 Edit: Here's what I've tried regarding the ent_remove problem: http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=395538#Post395538
Last edited by Germanunkol; 03/03/12 14:26.
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: ent_remove(my) crash?
[Re: FBL]
#396152
03/03/12 14:28
03/03/12 14:28
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
OP
Expert
|
OP
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
1) I did check the content of level. It was valid, in fact, it was the exact same string as the previous level load function call got, around 5 minutes earlier. 2) Is also a valid point, but if the entity was removed, all of the functions which have it as a "my" pointer would have been stopped and the my pointer set to NULL, according to the manual and all other tests I have made.
I've included a link at the end of my post above to a post where we've already tried quite a few things regarding the ent_remove problem. I've done quite a bit of logging, and the only thing that I can think of now is that only part of the entity memory has been overwritten, because the entity does still exist.
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: ent_remove(my) crash?
[Re: FBL]
#396168
03/03/12 16:34
03/03/12 16:34
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
OP
Expert
|
OP
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
Checked that as well, though. I log the my pointer at the beginning of the function and just before the ent_remove(my) is called. In both cases, it holds exactly the same value...
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: ent_remove(my) crash?
[Re: FBL]
#396181
03/03/12 18:25
03/03/12 18:25
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
OP
Expert
|
OP
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
Thanks for your ideas, either way!
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: ent_remove(my) crash?
[Re: Germanunkol]
#396222
03/04/12 10:54
03/04/12 10:54
|
Joined: Jul 2008
Posts: 894
TechMuc
User
|
User
Joined: Jul 2008
Posts: 894
|
I have no idea if the CRT Functions work with 3D Gamestudio or only with Visual Studio, though there might be a small probability that they work :-) So maybe you could try: _CrtSetDbgFlag(_CrtSetDebgFlag() | _CRTDBG_CHECK_ALWAYS_DF); (anywhere at the beginning of your code). This will check EVERY following allocation / free instruction for heap corruption and will therefore identify any mallicious function call. If this does not work, you could try _CrtCheckMemory(); which checks the validity of the heap (though this will probably not work either in this case ) Sources: http://msdn.microsoft.com/en-us/library/e73x0s4b(v=vs.71).aspx http://msdn.microsoft.com/en-us/library/5at7yxcs(v=vs.71).aspx PS: I'm also very interested in debugging your code with my cool editor (though it's not in work anymore ), so you can send it to me (if you want to) and i can check if I can find the error for you. PS:2 this will dramatically slow down the whole game, so if you use it, try to reproduce the crash and activate the "always check heap" flag only directly before (one frame before). If the heap-checking is just to slow, use the CrtCheckMemory function call.
Last edited by TechMuc; 03/04/12 10:57.
|
|
|
Re: ent_remove(my) crash?
[Re: Spirit]
#396242
03/04/12 15:44
03/04/12 15:44
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
OP
Expert
|
OP
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
I am hoping it is the same problem, yes. The first level load never crashes, but future level load calls sometimes do. It's all very unregular, but I do agree, it might be the same problem.
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
|