This will cause a very fast CTD with a stack overflow from the scripting VM:
Code: Select all
override bool CanCollideWith (Actor other, bool passive)
{
return CanCollideWith(other, passive);
}
Moderator: GZDoom Developers
Code: Select all
override bool CanCollideWith (Actor other, bool passive)
{
return CanCollideWith(other, passive);
}
Indeed. Not to mention that the the JIT doesn't even do that, it uses the real stack. And there can be direct calls that bypass the "VM exec" function.Professor Hastig wrote: ↑Mon Nov 13, 2023 1:54 am What VM stack? Aside from allocating the VM frames from the heap it just recursively calls the V'M's exec function.
ACS counts executed instructions. Not only can you not do this with a JIT, a far bigger problem is that ZScript code can be a lot more complex, there's code that can run magnitudes more than a simple ACS script.
While you are certainly correct, trying to second guess arbitrary code to avoid a stack overflow comes with a cost that's normally too high, this cannot be done without a severe performance or usability hit.Player701 wrote: ↑Mon Nov 13, 2023 3:27 am A hard freeze or crash is way more likely to cause the user to think there's something wrong with the engine itself, and even if VM functions get added to the crash log, I'm not sure most users actually bother reading them. A normal VM abort, on the other hand, usually makes it clear whether it's a mod or the engine that's at fault.
Just curious, but would it really incur that much overhead compared to other safety checks that are already present in the VM? For example, GZDoom does check for null pointer dereference in ZScript instead of just letting itself crash, and it also makes sure arrays are not accessed out of bounds. All of those definitely cost some performance, but on modern CPUs the difference is likely not noticeable at all.
What about SetThreadStackGuarantee? Looks like it's provided specifically to handle stack overflow exceptions, so perhaps it could be of use? (I have no idea of any equivalent for other platforms, though.)