[video output=day347 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Debugging Win32 Memory List Corruption" vod_platform=youtube id=wuYRpxnE9R8 annotator=Miblo]
[0:09][Recap and set the stage for the day]
[1:49][Run the game to demo the bug with the looped live code editing, and begin investigating it]
[5:48][win32_handmade.cpp: Walk through how PLATFORM_ALLOCATE_MEMORY(), PLATFORM_DEALLOCATE_MEMORY() and Win32FreeMemoryBlock() work]
[11:35][Step in to Win32FreeMemoryBlock() to gauge the rarity of this bug]
[15:34][win32_handmade.cpp: Introduce Win32VerifyMemoryListIntegrity()]
[19:11][win32_handmade.cpp: Make PLATFORM_ALLOCATE_MEMORY() call Win32VerifyMemoryListIntegrity() at the end and start, run and hit the one at the start]
[24:59][win32_handmade.cpp: Make Win32VerifyMemoryListIntegrity() increment a FailCounter, :run the game and locate the failure case]
[28:40][Step in to Win32VerifyMemoryListIntegrity() and identify who is getting written and when]
[30:35][Set a data breakpoint on the Size, run the game and see who touched that memory location]
[35:58][Look at where we set PushBufferBase, fix up RenderCommandsStruct() and correctly initialise the PushBuffer]
[38:01][Run the game and find that the bug is dead]
[38:46][win32_handmade.cpp: Remove the calls to Win32VerifyMemoryListIntegrity(), run the game and see that we're still okay]
[40:16][win32_handmade.cpp: Introduce Win32GetMemoryStats() in order to initialise arenas with debug information]
[43:43][handmade_platform.h: Introduce DEBUG_PLATFORM_GET_MEMORY_STATS()]
[46:26][handmade_debug.cpp: Enable DEBUGEnd() to print the memory stats]
[49:28][handmade_shared.h: Enable FormatStringList() to handle the l case]
[51:12][Run the game and consult the profiler]
[52:39][Q&A][:speech]
[53:29][@thesizik][long is >= 32 bits, long long is >= 64 bits]
[55:00][@pseudonym73][Windows is LLP64, everything else is LP64. The only difference between the two is the size of long. Everything else (short, int, long long) is the same]
[57:35][@zilarrezko][Is there any plan on organizing the episodes in a manner such as "Worked on mandalas on these episodes"?[ref
    site="YouTube"
    page="Handmade Hero Playlists"
    url="https://www.youtube.com/user/handmadeheroarchive/playlists"]]
[59:49][@Miblo][We'll have "category tagging" in the new annotation system]
[1:00:55][@doritosranger][Would Handmade Hero get a version for Linux or is it strictly a windows project? If it's true, why not using Linux in work? Is it personal choice or is it harder to debug something on windows?]
[1:04:14][@dudeinbasement1][Winners don't use drugs message needs to be added in the game's loading screen]
[1:04:30][@zilarrezko][Seems like the questions aren't polling in... Do you usually put your rendering / updating / input processing in the same function like you have been doing?]
[1:05:12][@edvinholm][Is the bending of the hero's body going to be like it is now? Looks a bit weird]
[1:05:43][@samnchiet][On moving from Windows to Linux, how much of the onus of making this change lies on the consumers vs Linux OS "designers"? Linux distros aren't normally ordinary-user friendly]
[1:06:31][@doritosranger][What do you think about free software (Stallman, FSF, GPL)?]
[1:13:08][Close it up][:speech]
[/video]
