diff -Nru ksh-93u+20120801/debian/changelog ksh-93u+20120801/debian/changelog --- ksh-93u+20120801/debian/changelog 2013-01-08 12:11:05.000000000 -0300 +++ ksh-93u+20120801/debian/changelog 2017-07-04 15:24:08.000000000 -0400 @@ -1,3 +1,10 @@ +ksh (93u+20120801-1ubuntu0.14.04.1) trusty; urgency=medium + + * d/p/locking.patch: Fix job locking mechanism to prevent + ksh to segfaults in job_chksave after receiving SIGCHLD. (LP: #1697501) + + -- Eric Desrochers Fri, 23 Jun 2017 16:01:04 -0400 + ksh (93u+20120801-1) unstable; urgency=low * New upstream release. diff -Nru ksh-93u+20120801/debian/patches/locking.patch ksh-93u+20120801/debian/patches/locking.patch --- ksh-93u+20120801/debian/patches/locking.patch 1969-12-31 21:00:00.000000000 -0300 +++ ksh-93u+20120801/debian/patches/locking.patch 2017-07-04 15:38:29.000000000 -0400 @@ -0,0 +1,37 @@ +Description: ksh segfaults in job_chksave after receiving SIGCHLD + Prior to this update, the compiler optimization dropped parts from the ksh job + locking mechanism from the binary code. As a consequence, ksh could terminate + unexpectedly with a segmentation fault after it received the SIGCHLD signal. + This update implements a fix to ensure the compiler does not drop parts of the + ksh mechanism and the crash no longer occurs. + +Author: Michal Hlavinka +Origin: Red Hat fix, ksh-20120801-locking.patch +Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1123467 +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1697501 +Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=867181 +--- a/src/cmd/ksh93/include/jobs.h ++++ b/src/cmd/ksh93/include/jobs.h +@@ -149,15 +149,18 @@ + #define vmbusy() 0 + #endif + +-#define job_lock() (job.in_critical++) ++#define asoincint(p) __sync_fetch_and_add(p,1) ++#define asodecint(p) __sync_fetch_and_sub(p,1) ++ ++#define job_lock() asoincint(&job.in_critical) + #define job_unlock() \ + do { \ + int sig; \ +- if (!--job.in_critical && (sig = job.savesig)) \ ++ if (asodecint(&job.in_critical)==1 && (sig = job.savesig)) \ + { \ +- if (!job.in_critical++ && !vmbusy()) \ ++ if (!asoincint(&job.in_critical) && !vmbusy()) \ + job_reap(sig); \ +- job.in_critical--; \ ++ asodecint(&job.in_critical); \ + } \ + } while(0) + diff -Nru ksh-93u+20120801/debian/patches/series ksh-93u+20120801/debian/patches/series --- ksh-93u+20120801/debian/patches/series 2012-07-12 01:20:06.000000000 -0400 +++ ksh-93u+20120801/debian/patches/series 2017-07-04 15:21:37.000000000 -0400 @@ -1,3 +1,4 @@ shell-options.patch cleanup-man-title.patch no-rpath.patch +locking.patch