Do not flush stdio streams on abort, assertion failure (#1498880)
This commit is contained in:
parent
eb8447b64e
commit
62a7902949
81
glibc-rh1498880-1.patch
Normal file
81
glibc-rh1498880-1.patch
Normal file
@ -0,0 +1,81 @@
|
||||
commit 91e7cf982d0104f0e71770f5ae8e3faf352dea9f
|
||||
Author: Florian Weimer <fweimer@redhat.com>
|
||||
Date: Thu Oct 5 14:48:16 2017 +0200
|
||||
|
||||
abort: Do not flush stdio streams [BZ #15436]
|
||||
|
||||
diff --git a/stdlib/abort.c b/stdlib/abort.c
|
||||
index 19882f3e3dc1ab83..117a507ff88d8624 100644
|
||||
--- a/stdlib/abort.c
|
||||
+++ b/stdlib/abort.c
|
||||
@@ -31,9 +31,6 @@
|
||||
# define ABORT_INSTRUCTION
|
||||
#endif
|
||||
|
||||
-#include <libio/libioP.h>
|
||||
-#define fflush(s) _IO_flush_all_lockp (0)
|
||||
-
|
||||
/* Exported variable to locate abort message in core files etc. */
|
||||
struct abort_msg_s *__abort_msg __attribute__ ((nocommon));
|
||||
libc_hidden_def (__abort_msg)
|
||||
@@ -67,16 +64,8 @@ abort (void)
|
||||
__sigprocmask (SIG_UNBLOCK, &sigs, 0);
|
||||
}
|
||||
|
||||
- /* Flush all streams. We cannot close them now because the user
|
||||
- might have registered a handler for SIGABRT. */
|
||||
- if (stage == 1)
|
||||
- {
|
||||
- ++stage;
|
||||
- fflush (NULL);
|
||||
- }
|
||||
-
|
||||
/* Send signal which possibly calls a user handler. */
|
||||
- if (stage == 2)
|
||||
+ if (stage == 1)
|
||||
{
|
||||
/* This stage is special: we must allow repeated calls of
|
||||
`abort' when a user defined handler for SIGABRT is installed.
|
||||
@@ -94,7 +83,7 @@ abort (void)
|
||||
}
|
||||
|
||||
/* There was a handler installed. Now remove it. */
|
||||
- if (stage == 3)
|
||||
+ if (stage == 2)
|
||||
{
|
||||
++stage;
|
||||
memset (&act, '\0', sizeof (struct sigaction));
|
||||
@@ -104,30 +93,22 @@ abort (void)
|
||||
__sigaction (SIGABRT, &act, NULL);
|
||||
}
|
||||
|
||||
- /* Now close the streams which also flushes the output the user
|
||||
- defined handler might has produced. */
|
||||
- if (stage == 4)
|
||||
- {
|
||||
- ++stage;
|
||||
- __fcloseall ();
|
||||
- }
|
||||
-
|
||||
/* Try again. */
|
||||
- if (stage == 5)
|
||||
+ if (stage == 3)
|
||||
{
|
||||
++stage;
|
||||
raise (SIGABRT);
|
||||
}
|
||||
|
||||
/* Now try to abort using the system specific command. */
|
||||
- if (stage == 6)
|
||||
+ if (stage == 4)
|
||||
{
|
||||
++stage;
|
||||
ABORT_INSTRUCTION;
|
||||
}
|
||||
|
||||
/* If we can't signal ourselves and the abort instruction failed, exit. */
|
||||
- if (stage == 7)
|
||||
+ if (stage == 5)
|
||||
{
|
||||
++stage;
|
||||
_exit (127);
|
153
glibc-rh1498880-2.patch
Normal file
153
glibc-rh1498880-2.patch
Normal file
@ -0,0 +1,153 @@
|
||||
commit 19f82f358670f4b80533156b9edbf81223358bf9
|
||||
Author: Andreas Schwab <schwab@suse.de>
|
||||
Date: Mon Aug 21 16:07:29 2017 +0200
|
||||
|
||||
Always do locking when iterating over list of streams (bug 15142)
|
||||
|
||||
_IO_list_all should only be traversed while locking list_all_lock.
|
||||
|
||||
diff --git a/libio/genops.c b/libio/genops.c
|
||||
index 6ad7346cae5c169d..89376d1b9bd7cf65 100644
|
||||
--- a/libio/genops.c
|
||||
+++ b/libio/genops.c
|
||||
@@ -38,10 +38,6 @@
|
||||
static _IO_lock_t list_all_lock = _IO_lock_initializer;
|
||||
#endif
|
||||
|
||||
-/* Used to signal modifications to the list of FILE decriptors. */
|
||||
-static int _IO_list_all_stamp;
|
||||
-
|
||||
-
|
||||
static _IO_FILE *run_fp;
|
||||
|
||||
#ifdef _IO_MTSAFE_IO
|
||||
@@ -69,16 +65,12 @@ _IO_un_link (struct _IO_FILE_plus *fp)
|
||||
if (_IO_list_all == NULL)
|
||||
;
|
||||
else if (fp == _IO_list_all)
|
||||
- {
|
||||
- _IO_list_all = (struct _IO_FILE_plus *) _IO_list_all->file._chain;
|
||||
- ++_IO_list_all_stamp;
|
||||
- }
|
||||
+ _IO_list_all = (struct _IO_FILE_plus *) _IO_list_all->file._chain;
|
||||
else
|
||||
for (f = &_IO_list_all->file._chain; *f; f = &(*f)->_chain)
|
||||
if (*f == (_IO_FILE *) fp)
|
||||
{
|
||||
*f = fp->file._chain;
|
||||
- ++_IO_list_all_stamp;
|
||||
break;
|
||||
}
|
||||
fp->file._flags &= ~_IO_LINKED;
|
||||
@@ -106,7 +98,6 @@ _IO_link_in (struct _IO_FILE_plus *fp)
|
||||
#endif
|
||||
fp->file._chain = (_IO_FILE *) _IO_list_all;
|
||||
_IO_list_all = fp;
|
||||
- ++_IO_list_all_stamp;
|
||||
#ifdef _IO_MTSAFE_IO
|
||||
_IO_funlockfile ((_IO_FILE *) fp);
|
||||
run_fp = NULL;
|
||||
@@ -794,17 +785,13 @@ _IO_flush_all_lockp (int do_lock)
|
||||
{
|
||||
int result = 0;
|
||||
struct _IO_FILE *fp;
|
||||
- int last_stamp;
|
||||
|
||||
#ifdef _IO_MTSAFE_IO
|
||||
- __libc_cleanup_region_start (do_lock, flush_cleanup, NULL);
|
||||
- if (do_lock)
|
||||
- _IO_lock_lock (list_all_lock);
|
||||
+ _IO_cleanup_region_start_noarg (flush_cleanup);
|
||||
+ _IO_lock_lock (list_all_lock);
|
||||
#endif
|
||||
|
||||
- last_stamp = _IO_list_all_stamp;
|
||||
- fp = (_IO_FILE *) _IO_list_all;
|
||||
- while (fp != NULL)
|
||||
+ for (fp = (_IO_FILE *) _IO_list_all; fp != NULL; fp = fp->_chain)
|
||||
{
|
||||
run_fp = fp;
|
||||
if (do_lock)
|
||||
@@ -823,21 +810,11 @@ _IO_flush_all_lockp (int do_lock)
|
||||
if (do_lock)
|
||||
_IO_funlockfile (fp);
|
||||
run_fp = NULL;
|
||||
-
|
||||
- if (last_stamp != _IO_list_all_stamp)
|
||||
- {
|
||||
- /* Something was added to the list. Start all over again. */
|
||||
- fp = (_IO_FILE *) _IO_list_all;
|
||||
- last_stamp = _IO_list_all_stamp;
|
||||
- }
|
||||
- else
|
||||
- fp = fp->_chain;
|
||||
}
|
||||
|
||||
#ifdef _IO_MTSAFE_IO
|
||||
- if (do_lock)
|
||||
- _IO_lock_unlock (list_all_lock);
|
||||
- __libc_cleanup_region_end (0);
|
||||
+ _IO_lock_unlock (list_all_lock);
|
||||
+ _IO_cleanup_region_end (0);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
@@ -856,16 +833,13 @@ void
|
||||
_IO_flush_all_linebuffered (void)
|
||||
{
|
||||
struct _IO_FILE *fp;
|
||||
- int last_stamp;
|
||||
|
||||
#ifdef _IO_MTSAFE_IO
|
||||
_IO_cleanup_region_start_noarg (flush_cleanup);
|
||||
_IO_lock_lock (list_all_lock);
|
||||
#endif
|
||||
|
||||
- last_stamp = _IO_list_all_stamp;
|
||||
- fp = (_IO_FILE *) _IO_list_all;
|
||||
- while (fp != NULL)
|
||||
+ for (fp = (_IO_FILE *) _IO_list_all; fp != NULL; fp = fp->_chain)
|
||||
{
|
||||
run_fp = fp;
|
||||
_IO_flockfile (fp);
|
||||
@@ -875,15 +849,6 @@ _IO_flush_all_linebuffered (void)
|
||||
|
||||
_IO_funlockfile (fp);
|
||||
run_fp = NULL;
|
||||
-
|
||||
- if (last_stamp != _IO_list_all_stamp)
|
||||
- {
|
||||
- /* Something was added to the list. Start all over again. */
|
||||
- fp = (_IO_FILE *) _IO_list_all;
|
||||
- last_stamp = _IO_list_all_stamp;
|
||||
- }
|
||||
- else
|
||||
- fp = fp->_chain;
|
||||
}
|
||||
|
||||
#ifdef _IO_MTSAFE_IO
|
||||
@@ -919,6 +884,12 @@ static void
|
||||
_IO_unbuffer_all (void)
|
||||
{
|
||||
struct _IO_FILE *fp;
|
||||
+
|
||||
+#ifdef _IO_MTSAFE_IO
|
||||
+ _IO_cleanup_region_start_noarg (flush_cleanup);
|
||||
+ _IO_lock_lock (list_all_lock);
|
||||
+#endif
|
||||
+
|
||||
for (fp = (_IO_FILE *) _IO_list_all; fp; fp = fp->_chain)
|
||||
{
|
||||
if (! (fp->_flags & _IO_UNBUFFERED)
|
||||
@@ -961,6 +932,11 @@ _IO_unbuffer_all (void)
|
||||
used. */
|
||||
fp->_mode = -1;
|
||||
}
|
||||
+
|
||||
+#ifdef _IO_MTSAFE_IO
|
||||
+ _IO_lock_unlock (list_all_lock);
|
||||
+ _IO_cleanup_region_end (0);
|
||||
+#endif
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
%define glibcsrcdir glibc-2.26-43-gfdf58ebc60
|
||||
%define glibcversion 2.26
|
||||
%define glibcrelease 10%{?dist}
|
||||
%define glibcrelease 11%{?dist}
|
||||
# Pre-release tarballs are pulled in from git using a command that is
|
||||
# effectively:
|
||||
#
|
||||
@ -231,6 +231,8 @@ Patch0060: glibc-rh1324623.patch
|
||||
|
||||
# Fix -Wstrict-overflow issues with gcc 7.0.
|
||||
Patch62: glibc-rh1416405.patch
|
||||
Patch63: glibc-rh1498880-1.patch
|
||||
Patch64: glibc-rh1498880-2.patch
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@ -803,6 +805,8 @@ microbenchmark tests on the system.
|
||||
%patch2115 -p1
|
||||
%patch2116 -p1
|
||||
%patch62 -p1
|
||||
%patch63 -p1
|
||||
%patch64 -p1
|
||||
|
||||
##############################################################################
|
||||
# %%prep - Additional prep required...
|
||||
@ -2217,6 +2221,9 @@ rm -f *.filelist*
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Sat Oct 7 2017 Florian Weimer <fweimer@redhat.com> - 2.26-11
|
||||
- Do not flush stdio streams on abort, assertion failure (#1498880)
|
||||
|
||||
* Sun Oct 01 2017 Florian Weimer <fweimer@redhat.com> - 2.26-10
|
||||
- Drop glibc-gcc-strict-overflow.patch, different workaround applied upstream.
|
||||
- Auto-sync with upstream release/2.26/master,
|
||||
|
Loading…
Reference in New Issue
Block a user