Files
swift-mirror/lib/Basic/OutputFileMap.cpp
Alex Hoppen a49994d72f [Driver] Don’t crash if the output file map is incomplete
When using VS Code, it semi-frequently happens that sourcekitd is reading the output file map and the memory buffer containing the memory buffer containing the output file map is not complete and terminates at distinct powers of 2. I managed to attach a debugger once and the memory buffer containing the output file had size 0x3000 = 12288 while the actual output file map is 20319 bytes large. One hypothesis for this is that the read of output file map is racing with a write from a SwiftPM build but I haven’t been able to confirm it.

In either case, the result is that the output file map buffer ends with an unterminated string literal, which causes `getKey()` or `getValue()` in the JSON parser to return `nullptr` and then consequently hits an assertion failure in `dyn_cast`. Add a check for nullptr before invoking `dyn_cast` just like we do it in the outer `for` loop.

rdar://122364031
2024-02-21 07:09:23 -08:00

8.2 KiB