Zeex/samp-plugin-crashdetect

Long callback execution detected (hang or performance issue)

tr1xy opened this issue ยท 12 comments

tr1xy commented
[14:48:50] [debug] Long callback execution detected (hang or performance issue)
[14:48:50] [debug] AMX backtrace:
[14:48:50] [debug] #0 0000a22c in Opcode:UnrelocateOpcode (Opcode:opcode=-1220407287) at C:\Users\Nemanja\Desktop\Valyria\pawno\include\YSI_Data\y_foreach\..\..\YSI_Coding\y_va\..\..\YSI_Core\y_core\..\..\amx\opcode.inc:831
[14:48:50] [debug] #1 00011058 in CodeScanRunFastPrescan (&proc=@0178b498 -8062576, &nextaddr=@0178b494 -8075992, searchFuncAddr=44812) at C:\Users\Nemanja\Desktop\Valyria\pawno\include\YSI_Data\y_foreach\..\..\YSI_Coding\y_va\..\..\YSI_Core\y_core\..\..\amx\codescan.inc:827
[14:48:50] [debug] #2 000114cc in bool:CodeScanRunFast (csState[CodeScanner:164]=@0178bcb4, searchFuncAddr=44812) at C:\Users\Nemanja\Desktop\Valyria\pawno\include\YSI_Data\y_foreach\..\..\YSI_Coding\y_va\..\..\YSI_Core\y_core\..\..\amx\codescan.inc:866
[14:48:50] [debug] #3 000133d8 in AddressofResolve () at C:\Users\Nemanja\Desktop\Valyria\pawno\include\YSI_Data\y_foreach\..\..\YSI_Coding\y_va\..\..\YSI_Core\y_core\..\..\amx\addressof_jit.inc:130
[14:48:50] [debug] #4 00013b38 in public AMX_OnCodeInit () at C:\Users\Nemanja\Desktop\Valyria\pawno\include\YSI_Data\y_foreach\..\..\YSI_Coding\y_va\..\..\YSI_Core\y_core\y_thirdpartyinclude.inc:367
[14:48:50] [debug] #5 0000343c in public Debug_OnCodeInit () at C:\Users\Nemanja\Desktop\Valyria\pawno\include\YSI_Data\y_foreach\..\..\YSI_Core\y_core\y_amx_impl.inc:206
[14:48:50] [debug] #6 00002d90 in public ScriptInit_OnCodeInit () at C:\Users\Nemanja\Desktop\Valyria\pawno\include\YSI_Data\y_foreach\..\..\YSI_Core\y_core\y_debug_impl.inc:644
[14:48:50] [debug] #7 00002644 in ScriptInit_CallOnCodeInit (bool:jit=false) at C:\Users\Nemanja\Desktop\Valyria\pawno\include\YSI_Data\y_foreach\..\..\YSI_Core\y_core\y_scriptinit_impl.inc:392
[14:48:50] [debug] #8 00002924 in public OnGameModeInit () at C:\Users\Nemanja\Desktop\Valyria\pawno\include\YSI_Data\y_foreach\..\..\YSI_Core\y_core\y_scriptinit_impl.inc:582

@Y-Less @Zeex :-/

It's meant to do that.

tr1xy commented

How is this useful though....?
I had to disable long hang cuz my commands wouldn't work (even tho gamemode was functional (everything except pawn.cmd))

rt-2 commented

@tr1xy use long_call_time 0 in server.cfg to disable this feature

tr1xy commented

@tr1xy use long_call_time 0 in server.cfg to disable this feature

I did already but this is pointless to have, especially when having YSI and OnScriptInit everywhere...

How long a top-level callback call should last before crashdetect prints a warning. This can be set very high (for example 1000000) to only detect functions that have totally hung, or very low (500) to detect functions that complete, but are just slow (thus affecting overall server execution and sync). Default value is 5000 (5 milliseconds).
(Zeex)
OnGameModeInit loaded sometimes very long time. So its semi-bug now.
This function very usefully to detect slow functions. But inappropriately for OnGameModeInit, it seems to me...
Is it possible to disable only public OnGameModeInit in CrashDetect?

rt-2 commented

How long a top-level callback call should last before crashdetect prints a warning. This can be set very high (for example 1000000) to only detect functions that have totally hung, or very low (500) to detect functions that complete, but are just slow (thus affecting overall server execution and sync). Default value is 5000 (5 milliseconds).
(Zeex)
OnGameModeInit loaded sometimes very long time. So its semi-bug now.
This function very usefully to detect slow functions. But inappropriately for OnGameModeInit, it seems to me...
Is it possible to disable only public OnGameModeInit in CrashDetect?

Similar to #pragma unused [arg](removes warning for unused function argument), there could a constant that we could define in function that would disable this check for that function?

But a simple solution would be to remove OnGamemodeInit and OnFilterscriptInit from the check because it is expected that most server will have slow functions there.

tr1xy commented

Yeah, especially heavy MySql loading... Anyways it doesn't matter as it is just a single ignore-able warning.

How is this useful though....?
I had to disable long hang cuz my commands wouldn't work (even tho gamemode was functional (everything except pawn.cmd))

If it stops something working that is a totally different bug and should be reported as such. This code should not stop anything working, just report slow code so you can try and make it faster.

However, you can disable it temporarily:

stock SetCrashDetectLongCallTime(us_time) {
// Setting this to `0` doesn't change the internal time, merely disables the check.
#emit load.s.pri us_time
#emit sctrl 0xFE
}
stock DisableCrashDetectLongCall() {
#emit const.pri 0
#emit sctrl 0xFE
}
stock EnableCrashDetectLongCall() {
#emit const.pri 2
#emit sctrl 0xFF
}
stock ResetCrashDetectLongCallTime() {
#emit const.pri 4
#emit sctrl 0xFF
}
stock RestartCrashDetectLongCall() {
#emit const.pri 8
#emit sctrl 0xFF
}
stock bool:IsCrashDetectLongCallEnabled() {
#emit zero.pri
#emit lctrl 0xFF
#emit shr.c.pri 1
#emit retn
return false;
}
stock GetCrashDetectLongCallTime() {
#emit zero.pri
#emit lctrl 0xFE
#emit retn
return 0;
}
// `GetCrashDetectDefaultLongCallTime` is too long.
stock GetCrashDetectDefaultTime() {
// store the current value
#emit zero.pri
#emit lctrl 0xFE
#emit move.alt
// reset to and read the default
#emit const.pri 4
#emit sctrl 0xFF
#emit zero.pri
#emit lctrl 0xFE
// put the current value back
#emit xchg
#emit sctrl 0xFE
#emit move.pri
#emit retn
return 0;
}

Yeah, especially heavy MySql loading... Anyways it doesn't matter as it is just a single ignore-able warning.

Again, the feature is to report potential issues in your code - if your MySQL loading is reported, that implies it is not threaded, which means again the plugin is working correctly to report a potential issue. You can't write bad code then complain that it is being reported as bad! Fix the code.

Also, the latest version of YSI already uses those functions I posted to disable the checks during its own startup, so if you're getting the errors you need to update YSI.

tr1xy commented

image

Nah, I had an error with OnScriptInit, not with the mysql, I just gave an example :')