No Error just a crash?

Posted By: alibaba

No Error just a crash? - 02/19/14 16:43

If you assign a skin of a model to the target_map of a panel and then change the level then the engine will just crash instead of giving an error.
Put this code into the sample folder and try it:

Code:
#include <acknex.h>
#include <default.c>


PANEL* test =
{
	bmap = "banana.bmp";
	flags=SHOW;
}

void main()
{
	level_load("");
	ENTITY* testc=ent_create("basket_ball.mdl",nullvector,NULL);
	camera.x=-100;
	//test.target_map=bmap_for_entity(testc,0);
	while(!key_k)wait(1);
	wait(-1);
	level_load("small.hmp");	
}



Comment out that line and youŽll see what i mean.

It took me nearly a week to find that nasty bug!
Posted By: Quad

Re: No Error just a crash? - 02/19/14 17:18

That's not a bug, and that's not something engine is supposed to tell you.

Because entities are destroyed your target_map pointer becomes NULL therefore you get a crash. They could have add check if target_map is NULL but then the people would try and wonder why their panels do not render at all etc..
Posted By: alibaba

Re: No Error just a crash? - 02/19/14 18:04

But this way i have no lead what may cause the crash, as it was some days ago.
Posted By: Superku

Re: No Error just a crash? - 02/19/14 18:17

The problem is that the engine has to know that the content of the pointer test.target_map is no longer valid to render into and I'm not sure how would one implement an error message for this efficiently.
However, it could be added to the manual as a note/ warning.
Posted By: alibaba

Re: No Error just a crash? - 02/19/14 20:21

Originally Posted By: Superku

However, it could be added to the manual as a note/ warning.

This sounds fair enought.
Posted By: Dico

Re: No Error just a crash? - 02/19/14 21:48

The code is work without crash for me , what is problem in it ?
Posted By: Dico

Re: No Error just a crash? - 02/19/14 21:52

oh sorry i forget to push button k , yes the engine crash
Posted By: Uhrwerk

Re: No Error just a crash? - 02/19/14 22:36

Originally Posted By: Superku
The problem is that the engine has to know that the content of the pointer test.target_map is no longer valid to render into and I'm not sure how would one implement an error message for this efficiently.
Well, the only option is checking every pointer before using it by iterating over the whole c_list thing. Does not sound reasonable in any way to me.
Originally Posted By: Superku
However, it could be added to the manual as a note/ warning.
What would such a warning look like? "Beware of vagabonding pointers!"?
Posted By: Superku

Re: No Error just a crash? - 02/19/14 22:39

Originally Posted By: Uhrwerk
I don't get it. How is the engine supposed to detect vagabonding pointers? And what would such a warning look like? "Beware of vagabonding pointers!"?

That's exactly what I said/ meant?

EDIT:
Quote:
Well, the only option is checking every pointer before using it by iterating over the whole c_list thing. Does not sound reasonable in any way to me.

And that's what I was thinking, yes (on deletion of one object).
Posted By: Uhrwerk

Re: No Error just a crash? - 02/19/14 22:49

On deletion is not sufficient. You could store the pointer in any variable and assign it later to the render target / whatever code may use it and crash.
Posted By: Superku

Re: No Error just a crash? - 02/19/14 23:08

Yes that's true but then you probably deserve a crash anyway. wink
Posted By: sivan

Re: No Error just a crash? - 02/20/14 07:33

I don't know too much about how the engine works internally, so I always use a level initialization and level closing function to set up and destroy things properly to avoid such a crash... and keeping loop quantity low is also a handy solution to clearly see through what happens.
© 2024 lite-C Forums