Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address naught write detection #111

Merged
merged 14 commits into from
Oct 10, 2022
Merged

Address naught write detection #111

merged 14 commits into from
Oct 10, 2022

Conversation

Y-Less
Copy link
Contributor

@Y-Less Y-Less commented Jul 2, 2022

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
Copy link
Contributor Author

Y-Less commented Jul 2, 2022

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

@Zeex
Copy link
Owner

Zeex commented Oct 10, 2022

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?

@Zeex Zeex merged commit 860f5c0 into Zeex:master Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants