Description
Linux builds have been broken since our upgrade to gcc 8 a few weeks ago. Apparently no one uses Linux nightlies, so no one noticed yet.
Initial investigation points to the ZERO_ON_NEW
macro we use to zero-initialize objects upon creations not working properly anymore in all cases.
// Auto clear a class when new'ed. (Won't work for inline creation.)
#define ZERO_ON_NEW \
void* operator new ( size_t size ) { void* ptr = ::operator new(size); memset(ptr,0,size); return ptr; } \
void* operator new ( size_t size, void* where ) { memset(where,0,size); return where; }
The comment there makes me assume that gcc 8 inlines more aggressively. We could disable inlining, but that's not a real fix. The proper course is to remove usage of ZERO_ON_NEW and directly initialize values to sane defaults. This is possible within the class declaration since c++11. MSVC does not seem to optimize this case yet, but medium-term we should also fix it for the client.
In general that macro seems like a terrible idea, because it would also not apply for objects on the stack.
Current State
As of right now we have 55 occurences in the public server code. @ccw808 what's the state in server net?
High Priority
- 53x Server Deathmatch
- 1x Dbconmy
- 1x Server SDK (ns_playerid.h)
- ?x Server Net
Low Priority
- 3x Game SA
- 1x Multiplayer SA
- 14x Client Deathmatch
- 28x Client Core
- ?x Client Net
Fixing strategy:
As the current code assumes we're initializing to 0, that's the simple choice.
- For trivial types (int, float, pointers) simply initialize to 0, nullptr or 0.0f according to the type.
- For complex types (std::vector, std::string, SString) skip.