Tue Feb 08, 2011 10:39 pm by Spike
hrm?
while I agree that a nan passed to a function that expects a string will cause an invalidly read string resulting in a crash, pr_argc is set by the op_call instruction. if pr_argc is wrong, then this can have only happened by using a buggy qcc, or buggy builtin prototypes. In terms of qcc bugs, nested function calls are the most likely way of getting a float where there should be a string parameter, nan or otherwise.
The solution presented above is a workaround for a specific instance, rather than a true fix. You can still have large floats (large exponants) that trigger the same error.
I don't know which line of QC is responsible for the error you report, but if it were recompiled with frikqcc, fteqcc, or qfcc, the issue would likely be fixed.
Perhaps worse is that a NaN is represented by the float containing the bits 0x7f800000 all set, as well as random other bits. This means that a negative NaN will be detected in the case where the string in question is within 8mb beneath the progs' string table on the heap. This includes classnames read from the bsp and stored in the zone memory within the heap.
At least I think that's how the maths works out.
Basically you can no longer print classnames if the engine its ported to still uses an 8mb heap. There's also another block of memory that cannot be poked, but that is a region of memory that would never normally be usable to store such a string in windows or linux.
A more correct test would perhaps be to fix the engine to store qc strings within only the heap (player netnames come to mind), and to then ensure the resulting string pointer is within that range. This would also have the benefit of fixing the qcvm on 64bit archetectures, assuming the heap is no larger than 2gb (depending on where the progs stringtable is located within the heap)...
A bigger concern to me is mods that send aprox 1024-char centerprints like teamfortress. Not only will that crash an unmodified client due to stack overflows/corruption, but it will also overflow the server's data section. 256 chars is just too small for too many centerprint-abusing mods.
Imho.