aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2021-03-10 12:07:24 -0800
committerNathan Sidwell <nathan@acm.org>2021-03-10 12:12:00 -0800
commit1f428775acc391c8ce4fcf79b243043f3333cc99 (patch)
tree3187ffcc82d5b59410e5a4518115786c38fe88cd /gcc
parent44fd4dc0b684e06c6c6d08b3994df23135bf2fbc (diff)
downloadgcc-1f428775acc391c8ce4fcf79b243043f3333cc99.zip
gcc-1f428775acc391c8ce4fcf79b243043f3333cc99.tar.gz
gcc-1f428775acc391c8ce4fcf79b243043f3333cc99.tar.bz2
c++: ICE do to GC leakage [PR 99423]
My reworking of pending-entity loading introduced a GC problem. The post-load processing needs to inhibit GCs (that would otherwise occur in clone_decl). That wasn't happening on one code path, leading to dangling pointers in the active call frames. PR c++/99423 gcc/cp/ * module.cc (post_load_processing): Assert not gcable. (laxy_load_pendings): Extend no-gc region around post_load_processing. gcc/testsuite/ * g++.dg/modules/pr99423_a.H: New. * g++.dg/modules/pr99423_b.H: New.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/module.cc6
-rw-r--r--gcc/testsuite/g++.dg/modules/pr99423_a.H13
-rw-r--r--gcc/testsuite/g++.dg/modules/pr99423_b.H6
3 files changed, 24 insertions, 1 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 2518d73..db5fa90 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -17194,6 +17194,10 @@ module_state::write_inits (elf_out *to, depset::hash &table, unsigned *crc_ptr)
static void
post_load_processing ()
{
+ /* We mustn't cause a GC, our caller should have arranged for that
+ not to happen. */
+ gcc_checking_assert (function_depth);
+
if (!post_load_decls)
return;
@@ -18882,9 +18886,9 @@ lazy_load_pendings (tree decl)
pending_table->remove (key);
dump.pop (n);
- function_depth--;
lazy_snum = 0;
post_load_processing ();
+ function_depth--;
}
timevar_stop (TV_MODULE_IMPORT);
diff --git a/gcc/testsuite/g++.dg/modules/pr99423_a.H b/gcc/testsuite/g++.dg/modules/pr99423_a.H
new file mode 100644
index 0000000..db3406c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/pr99423_a.H
@@ -0,0 +1,13 @@
+// PR 99423 ICE seeing GC freed entities
+// { dg-additional-options -fmodule-header }
+// { dg-module-cmi {} }
+template<typename _T1>
+struct pair
+{
+ pair() { }
+};
+
+inline pair<bool> blob ()
+{
+ return {};
+}
diff --git a/gcc/testsuite/g++.dg/modules/pr99423_b.H b/gcc/testsuite/g++.dg/modules/pr99423_b.H
new file mode 100644
index 0000000..c02ab29
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/pr99423_b.H
@@ -0,0 +1,6 @@
+// { dg-additional-options {-fmodule-header --param ggc-min-expand=0 --param ggc-min-heapsize=0} }
+// { dg-module-cmi {} }
+
+import "pr99423_a.H";
+
+pair<bool> boom();