Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, bigsmack, 7th_zorro, dr_panther), 1,364 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
ent_remove(my) crash? #396146
03/03/12 13:49
03/03/12 13:49
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline OP
Expert
Germanunkol  Offline 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)
Click to reveal.. (level_load crash)

Code:
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):
Click to reveal..
Code:
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):
Click to reveal..
Code:
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: Germanunkol] #396151
03/03/12 14:04
03/03/12 14:04
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Possibly stating the obvious, but anyway....

1) did you check the content of "level"? What was inside this string while the crash occured?
2) log the addresses where "me" and "you" are pointing to at that stage. I assume the pointers are not NULL while pointing at some entity which has already been removed. That would explain why the array access above (2nd example) does not yet crash, because you're not accessing some NULL pointer there.

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 Offline OP
Expert
Germanunkol  Offline 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: Germanunkol] #396153
03/03/12 14:36
03/03/12 14:36
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
2) not necessarily. When I developed Four Little Warriors I had some similar problem where entity functions continued running even after entity removal. The problem was, that at some point in the code, the my pointer could get wrecked and then would point to another entity.
The looping function checking for my therefore continued and so to say was reattached to a different entity.

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 Offline OP
Expert
Germanunkol  Offline 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: Germanunkol] #396174
03/03/12 16:53
03/03/12 16:53
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Guess I'm not of any help then.

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 Offline OP
Expert
Germanunkol  Offline 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
T
TechMuc Offline
User
TechMuc  Offline
User
T

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 laugh )

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 frown ), 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: TechMuc] #396232
03/04/12 14:27
03/04/12 14:27
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
Is your level also crashing when its the first level in your game? If not, both problems likely are the same, because when you load a level, the old level is unloaded and its entities are removed before.

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 Offline OP
Expert
Germanunkol  Offline 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
Page 1 of 2 1 2

Moderated by  old_bill, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1