Skip to content

Releases: Y-Less/samp-plugin-crashdetect

v4.22

27 Oct 13:39
Compare
Choose a tag to compare

Fixed some crashes in the plugin itself, especially when dealing with non-standard pawn code (read: #emit).

v4.21

01 Jul 17:47
Compare
Choose a tag to compare

Unofficial bug-fix release to stop people complaining about YSI startup messages.

  • Fix control registers on Linux.
  • Merge the address-naught detection code.

Address naught detection.

When there are internal code errors that result in the wrong address being written to, more often than not that write clobbers whatever value is in address naught (0x00000000), because the pointer is invalid. This happens enough that it can be worth entirely reserving that address as unused and catching all writes to it. While we can't stop all the bad address writes there are two things we can do - enable the anonymous automata, which is always at address naught, and never use it so that bad writes don't break something else, and enable address naught write detection in crashdetect. Note that this will have to be disabled if you use the anonymous automata. fixes.inc has an example of how to do this (as FIX_address_naught):

static stock _FIXES_CatchAddressNaught() <fix_address_naught>
{
	// Never set this state.  It merely causes the anonymous automata (which is
	// always located at address naught) to be included in the AMX (so we can
	// then not use it and keep it free to catch memory errors).
	#emit HALT         0x2E786966 // "fix." (little-endian).
}

static stock _FIXES_CatchAddressNaught() <>
{
	// Enable crashdetect catching address naught writes.
	#emit CONST.pri    192
	#emit SCTRL        0xFF
}

main()
{
	_FIXES_CatchAddressNaught();
}

Simply defining that function is sufficient to force the data to be at the start of DAT; but never call state fix_address_naught;.

Control of this feature is given by several functions in crashdetect.inc:

forward DisableCrashDetectAddr0();
forward EnableCrashDetectAddr0();
forward bool:IsCrashDetectAddr0Enabled();
forward bool:HasCrashDetectAddr0();