From fe414fcdd8a7c4d0aaf8b30afade7dc0d59ab2b7 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sat, 10 Feb 2018 15:35:12 +0100 Subject: [PATCH] Fix race condition in processFuncRequestQueue The issue here was that the element was only removed from the queue after the func request was processed, but within that process, other function could access the queue, so the queue could even be empty when this function finally wanted to remove the item. Fixes: #10406. (cherry picked from commit dadec50a18d92d24d42e1ccf7474f07a2a66b5b4) --- src/frontends/qt4/GuiApplication.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 97a60e9b44..35b639c9ac 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -2289,8 +2289,12 @@ void GuiApplication::processFuncRequestAsync(FuncRequest const & func) void GuiApplication::processFuncRequestQueue() { while (!d->func_request_queue_.empty()) { - processFuncRequest(d->func_request_queue_.front()); + // take the item from the stack _before_ processing the + // request in order to avoid race conditions from nested + // or parallel requests (see #10406) + FuncRequest const fr(d->func_request_queue_.front()); d->func_request_queue_.pop(); + processFuncRequest(fr); } }