Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by dr_panther. 05/18/24 11:01
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
2 registered members (7th_zorro, dr_panther), 724 guests, and 3 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 2 of 2 1 2
Re: Lite Foundation (now with beginner support) [Re: Quad] #346208
11/02/10 19:45
11/02/10 19:45
Joined: Apr 2009
Posts: 33
Germany
B
Bunsen Offline
Newbie
Bunsen  Offline
Newbie
B

Joined: Apr 2009
Posts: 33
Germany
I don't beleave that the error is caused by Lite-C (with different WINDOWS platforms).

You should verify this function call:

Code:
void timerCallback(LFTimerRef *timer)
{
   ...
   LFRelease(dateText); // <-- Exception Code 0xC0000005 (Protected memory access)
}



I hope it will help.

Re: Lite Foundation (now with beginner support) [Re: Quad] #346209
11/02/10 19:49
11/02/10 19:49
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline OP
Expert
WretchedSid  Offline OP
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Okay, I forced some other users to test it too (sadly no XP user), no one could confirm the crash (Nicotin Win 7, Michael_Schwarz Win 7, Hummel Win Vista).
I also tested it here on another PC running Windows XP but I still can't reproduce the crash.

Edit: @Bunsen, I don't see why the code should crash. It just frees some previous allocated memory and removes the dateText object from the current run loop.
I recreated the function here and went step by step through the code via LLDB and there is no illegal access =/
(Btw, Superku said that the crash occurs in the other timer callback and not in the one that fires every second)

Last edited by JustSid; 11/02/10 19:51.

Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Lite Foundation (now with beginner support) [Re: WretchedSid] #346210
11/02/10 20:09
11/02/10 20:09
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)

Code:
void createObject(LFTimerRef *timer)
{
	sys_marker("ABC");
	ENTITY *object = ent_create(CUBE_MDL, vector(2048, 0, 0), NULL); // "box.mdl"
	sys_marker(NULL);
	var force = 32;
	...

void main()
{
	level_load(NULL); 
	sys_marker("BBC");
	ENTITY *object = ent_create(CUBE_MDL, vector(2048, 0, 0), NULL); // "box.mdl"
	sys_marker(NULL);
	...



There is no error in the main function, only the ent_create-command in createObject fails.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Lite Foundation (now with beginner support) [Re: WretchedSid] #346211
11/02/10 20:11
11/02/10 20:11
Joined: Apr 2009
Posts: 33
Germany
B
Bunsen Offline
Newbie
Bunsen  Offline
Newbie
B

Joined: Apr 2009
Posts: 33
Germany
I'm using WINDOWS XP and it crashes.
You might run your program over night (or at least for maybe 2 hours).

Re: Lite Foundation (now with beginner support) [Re: Bunsen] #346214
11/02/10 20:41
11/02/10 20:41
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline OP
Expert
WretchedSid  Offline OP
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Bunsen, thank you very, very much! I managed to reproduce the bug, the problem is that I free a non allocated memory area.
You are right, LFRelease(dateText) does some bogus things that it shouldn't do.

What I don't know is why it does them, it looks like the dateText object somehow loses its retain count without an obvious reason. I will edit the post once I understand this completely, in the meantime: Stay away from LFDescription() (You can remove the very first timer to see the full demo (hopefully))


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Lite Foundation (now with beginner support) [Re: WretchedSid] #346216
11/02/10 21:09
11/02/10 21:09
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline OP
Expert
WretchedSid  Offline OP
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Edit: Okay, I'm stupid as hell. This is expected behavior, I was just too stupid to see it.
The problem is inside the LFRelease() function, it removes the object first from the run loop which releases the object again after it retained it, setting its retain count back to zero.
This works in all other cases because it leaves the retain count untouched, however it fails in this case for obvious reasons. Here is a working version of the LFRelease() function:
Code:
LFTypeRef *LFRelease(LFTypeRef *ref)
{
	if(ref->type == LFTYPE_ZOMBIE)
	{
		printf("Releasing already deallocated object %p!\n", ref);
		return NULL;
	}
	
	ref->retainCount -= 1;
	
	if(ref->retainCount == 0)
	{
		if(ref->type == LFTYPE_RUNLOOP)
		{
			LFRunLoop *runLoop = (LFRunLoop *)ref->data;
			
			if(runLoop->running) // A running runloop can't be deallocated!
			{
				runLoop->dirty		= 1;
				runLoop->shouldStop = 1;
				
				ref->retainCount ++;
				return ref;
			}
		}
		
		if(ref->runLoop && LFRunLoopCurrentRunLoop())
		{
			ref->retainCount = 2;
			LFRunLoopRemoveObject(LFRunLoopCurrentRunLoop(), ref);
			ref->retainCount = 0;
		}
		
		if(ref->pool)
		{
			LFAutoreleasePoolRef *_pool = (LFAutoreleasePoolRef *)ref->pool;
			
			ref->pool = NULL;
			ref->retainCount = 2; // Avoid double realeasing when removing the object from the array
			
		
			LFAutoreleasePool *pool = (LFAutoreleasePool *)_pool->data;
			LFArrayRemoveObject(pool->objects, ref);
			
			ref->retainCount = 0;
		}
		
		if(ref->dealloc)
			ref->dealloc(ref);
			
		if(ref->data)
			free(ref->data);
		
		if(!LFZombieFactory)
			free(ref);
		else
			ref->type = LFTYPE_ZOMBIE;
		
		return NULL;
	}
	
	return ref;
}



Please remark: I won't update the current version, you have to copy the patch manually as I'm almost finished with the next version (which will of course include the patch)!
Thanks superku and bunsen!

Edit: Whoops, this shouldn't be a double post. Sorry, clicked the wrong button. Can a mod please merge the two posts?

Last edited by JustSid; 11/02/10 21:10.

Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Page 2 of 2 1 2

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