6 ms·
So scary. I was working on a garbage collection bug for a AAA video game one time for months. It'd crash once a day on a tester machine and we'd add more and mo
by jbosh 2y ago
So scary. I was working on a garbage collection bug for a AAA video game one time for months. It'd crash once a day on a tester machine and we'd add more and more prints to try and narrow it down.
Finally got enough information and realized that the padding of a specific object was wrong (GC expected 16 bytes, object was 12 bytes). This caused dozens of other corruption bugs to disappear that we didn't even think were GC related.
- stingraycharles 2y agoHow is that possible? Which language was this in?
- jbosh 2y agoC++, it was an in house engine to make everything fit in memory on PS3. Removing fragmentation gave ~10% of usable memory back.
- stingraycharles 2y agoThat makes a lot of sense, I figured this would be impossible with a higher level language.
- taspeotis 2y agoAAA game is likely C++
- npalli 2y agoGC and AAA probably C#.
- mike_hearn 2y agoIf C# they'd have been using the MS authored GC. It was probably a custom GC for C++ heaps. Quite a few games do this, it's a smart productivity hack. Unreal uses a simple form of mark/sweep GC for its C++ game state heap. https://unrealcommunity.wiki/garbage-collection-36d1da https://unrealcommunity.wiki/garbage-collection-36d1da It works fine because most RAM in games is consumed by assets that don't need to be scanned.
- 60654 2y agoInteresting fact: Unity doesn't use a Microsoft GC, or the Microsoft implementation of CLR. They had integrated the competing Mono implementation early on, and it came with its own "stop the world" Boehm GC. They've been trying to move to Microsoft runtime for years but it's slow going.
- neonsunset 2y agoUnlikely. Though in the case of Unity, this can happen if you fail to uphold memory layout expectations when writing C/C++ code (or if you do something really bad in C#). There would also be a debugger allowing to reproduce and catch this in an easier way.
- rwmj 2y agoI don't know, but we had a similar bug in OCaml, although in reverse. Linux/x86-64 expects the stack to always be 16 byte aligned (although the ABI documentation at the time didn't make this assumption very clear). OCaml called into C with a non-aligned stack. GCC-generated code, assuming the stack was 16 byte aligned, used some strange Intel AVX instruction that only works on aligned data, unlike every other Intel instruction ever that can work on any alignment (albeit maybe more slowly). This manifested itself as rare and totally unreproducible crashes (because stack alignment differed between runs). It was a bit of a nightmare to solve.
- jbosh 2y agoThe fact that msvc generates the unaligned loads for every avx instruction but gcc didn't gave me so many headaches. Most people worked on PC or Xbox and I was on the Playstation team. "oh boy, another one of these..."
- rwmj 2y agoYes! It's one of those cases where when you've seen it before and know the catch with the instruction (probably vmovdqa) then you'll immediately recognise it. If you don't know it, it's very very mysterious. Why on earth Intel decided to make a handful of instructions require alignment is also a mystery to me.
- packetlost 2y agoProbably a custom one built for an in-house engine in C++ if it's a AAA studio. Alternatively one of the various off-the-shell ones you can #include, though my money is on the former. Note: I am not GP, I'm making educated guesses about what may have happened :)