diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2019-09-05 19:27:31 +0000 |
---|---|---|
committer | Iain Sandoe <iains@gcc.gnu.org> | 2019-09-05 19:27:31 +0000 |
commit | e451b91356d3e642f212d7183d8c23a47fb9903f (patch) | |
tree | 85b7633f96266d52ad2dc486eabdeeec85439eb2 /gcc/c | |
parent | e3b3d2b9dc74f2e0579a8a3086b5a0a1b57a4fc1 (diff) | |
download | gcc-e451b91356d3e642f212d7183d8c23a47fb9903f.zip gcc-e451b91356d3e642f212d7183d8c23a47fb9903f.tar.gz gcc-e451b91356d3e642f212d7183d8c23a47fb9903f.tar.bz2 |
[c-family] Backport fix for PCH / PR61250.
When we are parsing a source file, the very first token might
be a PRAGMA_GCC_PCH_PREPROCESS. This indicates that we are going
read in a PCH file (named as the value of the pragma). If we don't
see this pragma, then we know that it's OK to release any resources
that the host might have set aside for the PCH file.
There is a thinko in the current implementation, in that the decision
to release resources is happening unconditionally right after the first
token is extracted but before it's been checked or acted upon.
This leads to the pch bug on Darwin, because we actually do release
resources - which are subsequently (reasonably) assumed to be available
when reading a PCH file. We then get random crashes or hangs depending
on the interaction between unmmap and malloc.
The bug is present everywhere but doesn't show on (say) Linux, since
the release of PCH resources is a NOP there.
This effects all the c-family front ends, because they all use
c_lex_with_flags () to implement this.
The solution is to check for the PRAGMA_GCC_PCH_PREPROCESS and only call
c_common_no_more_pch () when that is not the first token.
A secondary effect of the collection is that the name of the PCH file
can be collected during the ggc_pch_read() reset of state. Therefore
we should issue any diagnostic that might name the file before the
collections are triggered.
gcc/
2019-09-05 Iain Sandoe <iain@sandoe.co.uk>
Backport from mainline
2019-08-23 Iain Sandoe <iain@sandoe.co.uk>
PR pch/61250
* ggc-page.c (ggc_pch_read): Read the ggc_pch_ondisk structure
and issue any diagnostics needed before collecting the pre-PCH
state.
gcc/c-family/
2019-09-05 Iain Sandoe <iain@sandoe.co.uk>
Backport from mainline
2019-08-23 Iain Sandoe <iain@sandoe.co.uk>
PR pch/61250
* c-lex.c (c_lex_with_flags): Don't call
c_common_no_more_pch () from here.
gcc/c
2019-09-05 Iain Sandoe <iain@sandoe.co.uk>
Backport from mainline.
2019-08-23 Iain Sandoe <iain@sandoe.co.uk>
PR pch/61250
* c-parser.c (c_parse_file): Call c_common_no_more_pch ()
after determining that the first token is not
PRAGMA_GCC_PCH_PREPROCESS.
gcc/cp/
2019-09-05 Iain Sandoe <iain@sandoe.co.uk>
Backported from mainline
2019-08-23 Iain Sandoe <iain@sandoe.co.uk>
PR pch/61250
* parser.c (cp_parser_initial_pragma): Call c_common_no_more_pch ()
after determining that the first token is not
PRAGMA_GCC_PCH_PREPROCESS.
From-SVN: r275431
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/c/c-parser.c | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 3944572..d7c5573 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,13 @@ +2019-09-05 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-08-23 Iain Sandoe <iain@sandoe.co.uk> + + PR pch/61250 + * c-parser.c (c_parse_file): Call c_common_no_more_pch () + after determining that the first token is not + PRAGMA_GCC_PCH_PREPROCESS. + 2019-08-30 Jakub Jelinek <jakub@redhat.com> Backported from mainline diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 86195c5..339b9a0 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -18214,6 +18214,8 @@ c_parse_file (void) if (c_parser_peek_token (&tparser)->pragma_kind == PRAGMA_GCC_PCH_PREPROCESS) c_parser_pragma_pch_preprocess (&tparser); + else + c_common_no_more_pch (); the_parser = ggc_alloc<c_parser> (); *the_parser = tparser; |