Dangling Pointer Issue
Years ago, when I worked at Gameloft as a server leader,
after 2 years of developing the 3D MMORPG Game Order and Chaos II.
We thought it was time to publish it.
On launch day, tens of thousands of players downloaded the game from the AppStore and connected to the servers.
As we celebrated the smooth running of the servers, one server crashed, then another…
I inspected the core dump file, and discovered it’s a dangling pointer issue : a memory block modified by a dangling pointer from another thread.
The crash didn’t occur when the memory was modified but when a thread tried to read the illegal data.
It was hard to reproduce, and there was no clue as to the root cause.
We had hundreds of classes that allocated memory, so we needed to trace every applied new/delete operator, it was a huge workload, and we had already gone live, with players complaining - it was urgent.
As the server leader, the whole team was counting on me.
I started coding a memory pool template, and applied it to all classes with bi-section method.
After hours of debugging and tracing, I found a way to reproduce the issue and finally pinpointed the buggy code.
This is the most impressive bug I’ve fixed.
