Assert in 'libgomp/target.c:gomp_unmap_vars_internal' that we're not unmapping 'tgt...
authorThomas Schwinge <thomas@codesourcery.com>
Wed, 18 Dec 2019 17:01:33 +0000 (18:01 +0100)
committerThomas Schwinge <tschwinge@gcc.gnu.org>
Wed, 18 Dec 2019 17:01:33 +0000 (18:01 +0100)
libgomp/
* target.c (gomp_unmap_vars_internal): Add a safeguard to
'gomp_remove_var'.

From-SVN: r279534

libgomp/ChangeLog
libgomp/target.c

index 472519c7e3e13d44c6dd94395673182537cd5cfd..541a2c7610c3d5fb32158430f2711f3e9a188f81 100644 (file)
@@ -1,5 +1,8 @@
 2019-12-18  Thomas Schwinge  <thomas@codesourcery.com>
 
+       * target.c (gomp_unmap_vars_internal): Add a safeguard to
+       'gomp_remove_var'.
+
        * target.c (gomp_to_device_kind_p): Handle 'GOMP_MAP_FORCE_FROM'
        like 'GOMP_MAP_FROM'.
 
index a3cdb34bd511146d4bc24e8dba909d5a77828573..67cd80a3c35edf87d63e81fa5c23841df57020f2 100644 (file)
@@ -1225,7 +1225,15 @@ gomp_unmap_vars_internal (struct target_mem_desc *tgt, bool do_copyfrom,
                                      + tgt->list[i].offset),
                            tgt->list[i].length);
       if (do_unmap)
-       gomp_remove_var (devicep, k);
+       {
+         struct target_mem_desc *k_tgt = k->tgt;
+         bool is_tgt_unmapped = gomp_remove_var (devicep, k);
+         /* It would be bad if TGT got unmapped while we're still iterating
+            over its LIST_COUNT, and also expect to use it in the following
+            code.  */
+         assert (!is_tgt_unmapped
+                 || k_tgt != tgt);
+       }
     }
 
   if (aq)