aboutsummaryrefslogtreecommitdiff
path: root/libgomp/task.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-02-08 09:30:17 +0100
committerJakub Jelinek <jakub@redhat.com>2022-02-08 09:30:17 +0100
commit0af7ef050aed9f678d70d79931ede38374fde863 (patch)
treec105f2acc20ab08dd9dc3befad16e9c92512a7ee /libgomp/task.c
parenta362158097352e9f2e4140d58a85ea3c0d95d3e4 (diff)
downloadgcc-0af7ef050aed9f678d70d79931ede38374fde863.zip
gcc-0af7ef050aed9f678d70d79931ede38374fde863.tar.gz
gcc-0af7ef050aed9f678d70d79931ede38374fde863.tar.bz2
libgomp: Fix segfault with posthumous orphan tasks [PR104385]
The following patch fixes crashes with posthumous orphan tasks. When a parent task finishes, gomp_clear_parent clears the parent pointers of its children tasks present in the parent->children_queue. But children that are still waiting for dependencies aren't in that queue yet, they will be added there only when the sibling they are waiting for exits. Unfortunately we were adding those tasks into the queues with the original task->parent which then causes crashes because that task is gone and freed. The following patch fixes that by clearing the parent field when we schedule such task for running by adding it into the queues and we know that the sibling task which is about to finish has NULL parent. 2022-02-08 Jakub Jelinek <jakub@redhat.com> PR libgomp/104385 * task.c (gomp_task_run_post_handle_dependers): If parent is NULL, clear task->parent. * testsuite/libgomp.c/pr104385.c: New test.
Diffstat (limited to 'libgomp/task.c')
-rw-r--r--libgomp/task.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/libgomp/task.c b/libgomp/task.c
index 53072d8..828348c 100644
--- a/libgomp/task.c
+++ b/libgomp/task.c
@@ -1248,6 +1248,8 @@ gomp_task_run_post_handle_dependers (struct gomp_task *child_task,
}
}
}
+ else
+ task->parent = NULL;
if (taskgroup)
{
priority_queue_insert (PQ_TASKGROUP, &taskgroup->taskgroup_queue,