Raised This Month: $344 Target: $400
 86%   Almost there!

Invalid Timer Handle crash


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 11-12-2020 , 13:48   Invalid Timer Handle crash
Reply With Quote #1

This crash's 100% of the time, and I'm not entirely sure why. I believe I've included all the related code below. All I'm attempting to do is kill the timer which would call the Humans win callback, but if all humans die prior to the time expiring then the timer needs to be killed.

PHP Code:
//Global Array
Handle g_hTimer;

//RoundStart callback
float delay 1.0 GetConVarInt(g_cvRoundTime) * 60 2;
g_hTimer CreateTimer(delayTimer_HumansWinEvent_TIMER_FLAG_NO_MAPCHANGE);

//RoundEnd callback (KillTimer is the error line)
if(g_hTimer != INVALID_HANDLE)
{
    
KillTimer(g_hTimer);
    
g_hTimer INVALID_HANDLE;
}

//Error
L 11/11/2020 15:22:01: [SMException reportedInvalid timer handle 686100fc (error 1)
L 11/11/2020 15:22:01: [SMBlamingcZomRevamp3.smx
L 11
/11/2020 15:22:01: [SMCall stack trace:
L 11/11/2020 15:22:01: [SM]   [0KillTimer 

Edit - Shouldn't need to add this here, but the game only crash's on RoundEnd when KillTimer is called. Otherwise no issues (that I've noticed).

Last edited by Halt; 11-12-2020 at 13:51.
Halt is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-12-2020 , 15:55   Re: Invalid Timer Handle crash
Reply With Quote #2

Quote:
Originally Posted by Halt View Post
This crash's 100% of the time, and I'm not entirely sure why. I believe I've included all the related code below. All I'm attempting to do is kill the timer which would call the Humans win callback, but if all humans die prior to the time expiring then the timer needs to be killed.

Code:
//Global Array
Handle g_hTimer;

//RoundStart callback
float delay = 1.0 * GetConVarInt(g_cvRoundTime) * 60 - 2;
g_hTimer = CreateTimer(delay, Timer_HumansWinEvent, _, TIMER_FLAG_NO_MAPCHANGE);

//RoundEnd callback (KillTimer is the error line)
if(g_hTimer != INVALID_HANDLE)
{
	KillTimer(g_hTimer);
	g_hTimer = INVALID_HANDLE;
}

//Error
L 11/11/2020 - 15:22:01: [SM] Exception reported: Invalid timer handle 686100fc (error 1)
L 11/11/2020 - 15:22:01: [SM] Blaming: cZomRevamp3.smx
L 11/11/2020 - 15:22:01: [SM] Call stack trace:
L 11/11/2020 - 15:22:01: [SM]   [0] KillTimer

Edit - Shouldn't need to add this here, but the game only crash's on RoundEnd when KillTimer is called. Otherwise no issues (that I've noticed).
Common mistake, using timer flag TIMER_FLAG_NO_MAPCHANGE
- This stop timer when map change.
- This not clear Handle were you created timer.
- Remove flag or clear Handle at OnMapStart()
Bacardi is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 11-13-2020 , 02:58   Re: Invalid Timer Handle crash
Reply With Quote #3

@Bacardi is OnMapEnd() guaranteed to fire every time and safe to CloseHandle() there or should i just do it on OnMapStart()?
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 11-13-2020 at 02:59.
GsiX is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 11-13-2020 , 06:40   Re: Invalid Timer Handle crash
Reply With Quote #4

Quote:
Originally Posted by GsiX View Post
@Bacardi is OnMapEnd() guaranteed to fire every time and safe to CloseHandle() there or should i just do it on OnMapStart()?
If your timer is stored into global variable you should use this example
Code:
public void OnMapEnd() {
	KillTimer( g_hTimer );
	g_hTimer = null;
}
or just
Code:
public void OnMapEnd() {
	delete g_hTimer;
}
__________________
MAGNAT2645 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-13-2020 , 17:10   Re: Invalid Timer Handle crash
Reply With Quote #5

Quote:
Originally Posted by GsiX View Post
@Bacardi is OnMapEnd() guaranteed to fire every time and safe to CloseHandle() there or should i just do it on OnMapStart()?
you can test it by yourself

PHP Code:

public void OnMapStart()
{
    
PrintToServer("-- OnMapStart");
}

public 
void OnMapEnd()
{
    
PrintToServer("-- OnMapEnd");

Bacardi is offline
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 11-15-2020 , 14:53   Re: Invalid Timer Handle crash
Reply With Quote #6

Thanks Bacardi, and Mag. No more crash's
Halt is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine
Old 11-21-2020 , 18:18   Re: Invalid Timer Handle crash
Reply With Quote #7

Here are most cases about the freeing timer's handle covered with explanations.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch)
[My plugins] [My tools] [GitHub] [Articles] [Donate]
Dragokas is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:43.


Powered by vBulletin®
Copyright ©2000 - 2022, vBulletin Solutions, Inc.
Theme made by Freecode