]> git.ipfire.org Git - thirdparty/gcc.git/commit
PCH: Make the save and restore diagnostics more robust.
authorIain Sandoe <iain@sandoe.co.uk>
Sat, 13 Nov 2021 12:26:16 +0000 (12:26 +0000)
committerIain Sandoe <iain@sandoe.co.uk>
Tue, 16 Nov 2021 19:42:35 +0000 (19:42 +0000)
commite4641191287ca613529d78a906afe4f029c1c3cd
tree36b948e20a0b63f8c27845aa38866e73534dd0ec
parent4cdf7db9a39d18bd536d816a5751d4d3cf23808b
PCH: Make the save and restore diagnostics more robust.

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-oin 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.

Signed-off-by: Iain Sandoe <iain@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.
gcc/ggc-common.c