From 3b4edba158c3430cb103594c140b01a5593c23e3 Mon Sep 17 00:00:00 2001 From: "David Kaspar [Dee'Kej]" Date: Tue, 3 May 2016 12:41:14 +0200 Subject: [PATCH] tcsh-6.19.00-003-avoid-gcc5-calloc-optimization.patch added > avoid gcc-5 optimization malloc + memset = calloc (Fridolin Pokorny) --- ...0-003-avoid-gcc5-calloc-optimization.patch | 59 +++++++++++++++++++ tcsh-6.19.00-gcc5-calloc.patch | 18 ------ tcsh.spec | 4 +- 3 files changed, 61 insertions(+), 20 deletions(-) create mode 100644 tcsh-6.19.00-003-avoid-gcc5-calloc-optimization.patch delete mode 100644 tcsh-6.19.00-gcc5-calloc.patch diff --git a/tcsh-6.19.00-003-avoid-gcc5-calloc-optimization.patch b/tcsh-6.19.00-003-avoid-gcc5-calloc-optimization.patch new file mode 100644 index 0000000..bb87850 --- /dev/null +++ b/tcsh-6.19.00-003-avoid-gcc5-calloc-optimization.patch @@ -0,0 +1,59 @@ +From 624d3aebb6e6afadb4f35e894d11b5ebe290cd87 Mon Sep 17 00:00:00 2001 +From: christos +Date: Thu, 28 May 2015 11:47:03 +0000 +Subject: [PATCH 1/2] avoid gcc-5 optimization malloc + memset = calloc + (Fridolin Pokorny) + +--- + tc.alloc.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/tc.alloc.c b/tc.alloc.c +index b9aec63..c1cb330 100644 +--- a/tc.alloc.c ++++ b/tc.alloc.c +@@ -348,10 +348,13 @@ calloc(size_t i, size_t j) + { + #ifndef lint + char *cp; ++ size_t k; + + i *= j; + cp = xmalloc(i); +- memset(cp, 0, i); ++ /* Stop gcc 5.x from optimizing malloc+memset = calloc */ ++ k = i; ++ memset(cp, 0, k); + + return ((memalign_t) cp); + #else +-- +2.5.5 + + +From 05e7406049bd2686dee0ee8d819dcd38eb131f6f Mon Sep 17 00:00:00 2001 +From: christos +Date: Tue, 7 Jul 2015 12:24:54 +0000 +Subject: [PATCH 2/2] make k volatile to prevent gcc-5 memset() optimization + (Fridolin Pokorny) + +--- + tc.alloc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tc.alloc.c b/tc.alloc.c +index c1cb330..f68a8c5 100644 +--- a/tc.alloc.c ++++ b/tc.alloc.c +@@ -348,7 +348,7 @@ calloc(size_t i, size_t j) + { + #ifndef lint + char *cp; +- size_t k; ++ volatile size_t k; + + i *= j; + cp = xmalloc(i); +-- +2.5.5 + diff --git a/tcsh-6.19.00-gcc5-calloc.patch b/tcsh-6.19.00-gcc5-calloc.patch deleted file mode 100644 index 3e404f8..0000000 --- a/tcsh-6.19.00-gcc5-calloc.patch +++ /dev/null @@ -1,18 +0,0 @@ -diff --git a/tc.alloc.c b/tc.alloc.c -index b87f9e9..06e0405 100644 ---- a/tc.alloc.c -+++ b/tc.alloc.c -@@ -348,10 +348,12 @@ calloc(size_t i, size_t j) - { - #ifndef lint - char *cp; -+ volatile size_t k; - - i *= j; - cp = xmalloc(i); -- memset(cp, 0, i); -+ k = i; -+ memset(cp, 0, k); - - return ((memalign_t) cp); - #else diff --git a/tcsh.spec b/tcsh.spec index fc5d58d..0f5fb20 100644 --- a/tcsh.spec +++ b/tcsh.spec @@ -31,6 +31,7 @@ Source: ftp://ftp.astron.com/pub/tcsh/%{name}-%{version}.tar.gz Patch000: tcsh-6.19.00-000-announcement.patch Patch001: tcsh-6.19.00-001-remove-CFLAGS-for-gethost.patch Patch002: tcsh-6.19.00-002-fix-error-messages.patch +Patch003: tcsh-6.19.00-003-avoid-gcc5-calloc-optimization.patch # Downstream patches -- these should be always included when doing rebase: @@ -40,10 +41,8 @@ Patch100: tcsh-6.19.00-manpage-memoryuse.patch # Patches to be removed -- deprecated functionality which shall be removed at # --------------------- some point in the future: -Patch101: tcsh-6.19.00-gcc5-calloc.patch Patch102: tcsh-6.19.00-tcsh_posix_status-deprecated.patch -# NOTE: Patch101 has been accepted by upstream - http://mx.gw.com/pipermail/tcsh-bugs/2015-May/000944.html # NOTE: Patch102 should be removed in Fedora 25! @@ -156,6 +155,7 @@ fi tcsh-6.19.00-000-announcement.patch tcsh-6.19.00-001-remove-CFLAGS-for-gethost.patch tcsh-6.19.00-002-fix-error-messages.patch + tcsh-6.19.00-003-avoid-gcc5-calloc-optimization.patch (replaces tcsh-6.19.00-gcc5-calloc.patch) * Thu Apr 21 2016 David Kaspar [Dee'Kej] - 6.19.00-6 - Drop tcsh-6.15.00-closem.patch - issue not reproducible, patch not accepted by upstream