Zeex / samp-plugin-crashdetect

Crash/error reporting plugin for SA-MP server
http://forum.sa-mp.com/showthread.php?t=262796
BSD 2-Clause "Simplified" License
116 stars 23 forks source link

Address naught write detection #111

Closed Y-Less closed 1 year ago

Y-Less commented 2 years ago

Adds detection for writing to address 0 (not always an error) and flags to control it.:

# Address Naught

Often writing to address naught is a mistake, it indicates that some target address is unset,
especially in larger modes.  `address_naught` mode detects all writes to this address and gives a
new (to VM) error in that case - `AMX_ERR_ADDRESS_0`.  Note that this isn't always an error, it is a
valid address and real data can be stored there, so if this detection is enabled the mode must
ensure that nothing important will be written there (fixes.inc does this by defining and not using
the anonymous automata).

## Functions

There are several functions in the include to use these tests:

* `DisableCrashDetectAddr0();` - Disable address naught write detection in this mode.
* `EnableCrashDetectAddr0();` - Enable address naught write detection in this mode.
* `bool:IsCrashDetectAddr0Enabled();` - Is the error currently enabled?
* `bool:HasCrashDetectAddr0();` - Does the current version of crashdetect support this feature?

This also cleaned up some other register uses.

Y-Less commented 2 years ago

Made a new PR as I pushed some new irrelevant commits to the old one (which was from master).

Zeex commented 1 year ago

Thanks Y_Less, this is surely a useful feature to have. And thanks for the comprehensive documentation, appreciate it. I've merged this locally with some minor formatting corrections in README (I hope you don't mind) and with a fix to enable the address_naught test in order to make it run together with the other tests when using make test.

On a side note, I noticed today that the long call detection test (long_call_ok) sometimes fails on my machine (Intel i5-7500) with the default setting of 5000, but 10000 works pretty stable. I wonder if this might be the case for other users and if it might be necessary to increase the default. What do you think?