Day 536 macOS Platform Layer Bug
2 weeks, 6 days ago Edited by Chris on May 29, 2019, 6:04 p.m. Reason: Initial post
I mentioned in the pre-stream of episode 536 that my macOS platform layer crashes when building under Xcode with the address sanitizer enabled.
Having spent a bit more time debugging, I found my issue. In the code for day 536, win32_handmade.cpp at line 1417, both Result->BaseName and Result->Platform are set. Platform is set to a new UTF16 string that is pushed onto the filegroup’s memory, but BaseName is set to the supplied Path, which is local the various callers in handmade_import.cpp. Not needing to deal with UTF16 on macOS, I set them both to Path…
After, when Win32OpenFile is called, it uses the Platform pointer, so it works properly. In my platform layer, it points to old memory. So, I think the BaseName pointer in the win32 layer is also incorrect. In GetFileByPath, the supplied path needs to be copied to the filegroup, which Win32GetAllFilesOfTypeBegin already does.