7 Bug-Reported-by: Christian Weisgerber <naddy@mips.inka.de>
8 Bug-Reference-ID: <20161101160302.GB54856@lorvorc.mips.inka.de>
9 Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2016-11/msg00004.html
13 There is a race condition that can result in bash referencing freed memory
14 when freeing data associated with the last process substitution.
16 Patch (apply with `patch -p0'):
18 *** ../bash-4.4/jobs.c 2016-08-23 16:38:44.000000000 -0400
19 --- jobs.c 2016-11-02 18:24:45.000000000 -0400
26 + discard_last_procsub_child ()
31 + BLOCK_CHILD (set, oset);
32 + disposer = last_procsub_child;
33 + last_procsub_child = (PROCESS *)NULL;
34 + UNBLOCK_CHILD (oset);
37 + discard_pipeline (disposer);
40 struct pipeline_saver *
41 alloc_pipeline_saver ()
42 *** ../bash-4.4/jobs.h 2016-04-27 10:35:51.000000000 -0400
43 --- jobs.h 2016-11-02 18:25:08.000000000 -0400
47 extern void stop_making_children __P((void));
48 extern void cleanup_the_pipeline __P((void));
49 + extern void discard_last_procsub_child __P((void));
50 extern void save_pipeline __P((int));
51 extern PROCESS *restore_pipeline __P((int));
52 *** ../bash-4.4/subst.c 2016-08-30 16:46:38.000000000 -0400
53 --- subst.c 2016-11-02 18:23:24.000000000 -0400
56 #if defined (JOB_CONTROL)
57 if (last_procsub_child)
59 ! discard_pipeline (last_procsub_child);
60 ! last_procsub_child = (PROCESS *)NULL;
62 last_procsub_child = restore_pipeline (0);
65 #if defined (JOB_CONTROL)
66 if (last_procsub_child)
67 ! discard_last_procsub_child ();
68 last_procsub_child = restore_pipeline (0);
70 *** ../bash-4.4/patchlevel.h 2016-06-22 14:51:03.000000000 -0400
71 --- patchlevel.h 2016-10-01 11:01:28.000000000 -0400
74 looks for to find the patch level (for the sccs version string). */
76 ! #define PATCHLEVEL 3
78 #endif /* _PATCHLEVEL_H_ */
80 looks for to find the patch level (for the sccs version string). */
82 ! #define PATCHLEVEL 4
84 #endif /* _PATCHLEVEL_H_ */