File GSCreator-Fix-hang-due-to-calling-exit-after-fork.patch of Package kdegraphics-thumbnailers.12773

From 3e2ea6e924d0e2a2cdd9bb435b06965117d6d34c Mon Sep 17 00:00:00 2001
From: Ambroz Bizjak <abizjak.pro@gmail.com>
Date: Sun, 19 Jan 2020 21:34:32 +0100
Subject: GSCreator: Fix hang due to calling exit() after fork()

Summary:
After fork(), exit() invokes atexit handlers, which can result in a lockup if an atexit handler uses thread synchronization facilities, since all but the current thread no longer exist. An example backtrace can be found in the linked bug report. Fix it by using _exit() instead of exit().

BUG: 404652
FIXED-IN: 20.03.80

Test Plan: I don't know the exact environment required to trigger this bug, but one precondition is to trigger generation of thumbnails via this code; maybe browsing folders with PDF files will do that. Once you see thumbnail.so processes staying around, you must have hit this bug. This patch should prevent this issue from occurring, and it did on my system.

Reviewers: #frameworks, elvisangelaccio

Reviewed By: elvisangelaccio

Subscribers: elvisangelaccio

Differential Revision: https://phabricator.kde.org/D26635
---
 ps/gscreator.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/ps/gscreator.cpp b/ps/gscreator.cpp
index 2fba4c5..e281a9e 100644
--- a/ps/gscreator.cpp
+++ b/ps/gscreator.cpp
@@ -350,7 +350,7 @@ bool GSCreator::create(const QString &path, int width, int height, QImage &img)
 	dup2( dvipipe[1], STDOUT_FILENO);
 
 	execvp(dvipsargs[0], const_cast<char *const *>(dvipsargs));
-	exit(1);
+	_exit(1);
       }
       else if(pid_two != -1){
 	close(input[1]);
@@ -361,7 +361,7 @@ bool GSCreator::create(const QString &path, int width, int height, QImage &img)
 	dup2( output[1], STDOUT_FILENO);
 
 	execvp(gsargs[0], const_cast<char *const *>(gsargs));
-	exit(1);
+	_exit(1);
       }
       else{
 	// fork() (2) failed, close these
@@ -379,7 +379,7 @@ bool GSCreator::create(const QString &path, int width, int height, QImage &img)
       dup2(output[1], STDOUT_FILENO);
 
       execvp(gsargs[0], const_cast<char *const *>(gsargs));
-      exit(1);
+      _exit(1);
     }
   }
   else if (pid != -1) {
-- 
cgit v1.1

openSUSE Build Service is sponsored by