On 11/13/2021 6:10 AM, Iain Sandoe via Gcc-patches wrote:
When saving, if we cannot obtain a suitable memory segment there is no point in continuing, so exit with an error. When reading in the PCH, we have a situation that the read-in data will replace the line tables used by the diagnostics output. However, the state of the read-in line tables is indeterminate at some points where diagnostics might be needed. To make this more robust, we save the existing line tables at the start and, once we have read in the pointer to the new one, put that to one side and restore the original table. This avoids compiler hangs if the read or memory acquisition code issues an assert, fatal_error, segv etc. Once the read is complete, we swap in the new line table that came from the PCH. If the read-in PCH is corrupted then we still have a broken compilation w.r.t any future diagnostics - but there is little that can be done about that without more careful validation of the file. I've tested this by hacking and rebuilding the compiler to produce various kinds of failure. At present, it is hard to see how to make testcases to do this. Now reg-testing on more systems, OK for master if reg-tests pass? thanks Iain Signed-off-by: Iain Sandoe <i...@sandoe.co.uk> gcc/ChangeLog: * ggc-common.c (gt_pch_save): If we cannot find a suitable memory segment for save, then error-out, do not try to continue. (gt_pch_restore): Save the existing line table, and when the replacement is being read, use that when constructing diagnostics.
OK if it passes. Jeff