AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   General (https://forums.alliedmods.net/forumdisplay.php?f=58)
-   -   New Feature: Watchdog Timer (https://forums.alliedmods.net/showthread.php?t=223553)

BAILOPAN 08-15-2013 02:56

New Feature: Watchdog Timer
 
Hi All,

If you're using SourceMod 1.6 snapshots, I've just added an experimental feature. If a plugin takes too long to execute - for example, it has a bug that causes your server to hang or infinite loop - SourceMod will now try to terminate the plugin. If that happens you'll get an error like this:

Code:

L 08/14/2013 - 23:47:20: [SM] Plugin encountered error 30: Script execution timed out
L 08/14/2013 - 23:47:20: [SM] Displaying call stack trace for plugin "test.smx":
L 08/14/2013 - 23:47:20: [SM]  [0]  Line 13, test.sp::OnPluginStart()

This feature is zero-cost and should not incur any performance overhead. I've also taken care to make sure it doesn't introduce spurious timeouts where none occurred. However, if you find any bugs, please do let me know.

The timeout can be configured or disabled in core.cfg via the new "SlowScriptTimeout" option. It defaults to 8 seconds.

Thanks!

hlstriker 08-15-2013 03:11

Re: New Feature: Watchdog Timer
 
What exactly is watchdog? Ages ago I set -nowatchdog in my startup line and I honestly can't even remember why.

Pretty neat feature though :)

BAILOPAN 08-15-2013 03:15

Re: New Feature: Watchdog Timer
 
It's a general term for anything that watches to make sure nothing's malfunctioning. Like when a webpage takes too long to load, most browsers have a "This script is taking too long..." dialog. That's a watchdog timer of some kind.

Sreaper 08-15-2013 04:32

Re: New Feature: Watchdog Timer
 
Awesome! Thanks Bailopan!

Peace-Maker 08-15-2013 08:25

Re: New Feature: Watchdog Timer
 
It'll be interesting to see what plugins actually reach such a timeout. I'd expect it to be very rare?

LouLouBizou 08-15-2013 11:24

Re: New Feature: Watchdog Timer
 
heap memoty leak fixed in last dev 1.6 ?

BAILOPAN 08-15-2013 13:21

Re: New Feature: Watchdog Timer
 
Quote:

Originally Posted by Peace-Maker (Post 2013667)
It'll be interesting to see what plugins actually reach such a timeout. I'd expect it to be very rare?

I would expect it to be rare as well. It may end up being more of a developer feature, everyone's probably accidentally locked up their server once or twice writing a complex plugin.

thetwistedpanda 08-15-2013 14:53

Re: New Feature: Watchdog Timer
 
once or twice? I've been doing it a few times a week for three years. tis a wonderful feature xD.

ElooKoN 11-04-2015 11:33

Re: New Feature: Watchdog Timer
 
Good feature!

But today I got this error message. Probably caused by slow hardware I/O because the error occurred after rebooting the physical machine:

Code:

L 11/04/2015 - 11:00:12: [SM] Plugin encountered error 30: Script execution timed out
L 11/04/2015 - 11:00:12: [SM] Displaying call stack trace for plugin "Plugin.smx":
L 11/04/2015 - 11:00:12: [SM]  [0]  Line 329, addons/sourcemod/scripting/include/string.inc::StrEqual()
L 11/04/2015 - 11:00:12: [SM]  [1]  Line 2551, inc/common.inc.compile::RemoveOldFiles()
L 11/04/2015 - 11:00:12: [SM]  [2]  Line 2543, inc/common.inc.compile::TidyUp()
L 11/04/2015 - 11:00:12: [SM]  [3]  Line 105, base.inc.compile::OnPluginStart()

I am wondering why it stops at StrEqual() and not at ReadDirEntry() or OpenDirectory()?

Code:

stock RemoveOldFiles(const String:directory[], const MaxAge) {
       
        new FileTime;
       
        decl String:filename[32];
        decl String:FilePath[64];
       
        new Handle:dir = OpenDirectory(directory);
       
        while (ReadDirEntry(dir, filename, sizeof(filename))) {
       
                if (!StrEqual(filename, ".") && !StrEqual(filename, "..")) {
                       
                        ...
               
                }

        }
       
        CloseHandle(dir);
       
}

Maybe it is a bug of StrEqual(). Line 329 in string.inc is:

Code:

native bool:IsCharAlpha(chr);
I'm using Sourcemod 1.7, Build 5272.

Potato Uno 11-04-2015 12:51

Re: New Feature: Watchdog Timer
 
I think the watchdog timer begins a timer when a function in the plugin is first invoked, and if the whole operation takes more than 8 seconds it just kills the entire stack. I'm not sure however.


All times are GMT -4. The time now is 22:38.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.