commit: d7cd02e1aa9ef37a0aee0d4f2507b8f21b522c7b Author: Ulrich Müller <ulm <AT> gentoo <DOT> org> AuthorDate: Sat Feb 18 07:12:10 2017 +0000 Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org> CommitDate: Sat Feb 18 07:12:10 2017 +0000 URL: https://gitweb.gentoo.org/proj/emacs-tools.git/commit/?id=d7cd02e1
Fix temacs segmentation fault due to endless calloc loop. emacs/24.5/07_all_gmalloc.patch | 81 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/emacs/24.5/07_all_gmalloc.patch b/emacs/24.5/07_all_gmalloc.patch new file mode 100644 index 0000000..7698ee3 --- /dev/null +++ b/emacs/24.5/07_all_gmalloc.patch @@ -0,0 +1,81 @@ +Fix temacs segmentation fault due to endless calloc loop. +https://bugs.gentoo.org/609680 + +Backported from Emacs 25: + +commit 4b1436b702d56eedd27a0777fc7232cdfb7ac4f6 +Author: Wolfgang Jenkner <[email protected]> +Date: Sat Dec 26 12:12:02 2015 -0800 + + Always define gmalloc etc. in src/gmalloc.c + + This is a work-around to prevent the compiler from using semantic + knowledge about malloc for optimization purposes. E.g., gcc 5.2 + with -O2 replaces most of calloc's definition by a call to calloc; + see Bug#22085. + * src/gmalloc.c [!HYBRID_MALLOC] (malloc, realloc, calloc) + (aligned_alloc, free): Do not undef. Instead, define these as + functions (perhaps renamed to gmalloc etc.) in terms of gmalloc etc. + +--- emacs-24.5-orig/src/gmalloc.c ++++ emacs-24.5/src/gmalloc.c +@@ -42,6 +42,16 @@ + extern void emacs_abort (void); + #endif + ++#undef malloc ++#undef realloc ++#undef calloc ++#undef free ++#define malloc gmalloc ++#define realloc grealloc ++#define calloc gcalloc ++#define aligned_alloc galigned_alloc ++#define free gfree ++ + #ifdef __cplusplus + extern "C" + { +@@ -1747,6 +1757,42 @@ + return aligned_alloc (pagesize, size); + } + ++#undef malloc ++#undef realloc ++#undef calloc ++#undef aligned_alloc ++#undef free ++ ++void * ++malloc (size_t size) ++{ ++ return gmalloc (size); ++} ++ ++void * ++calloc (size_t nmemb, size_t size) ++{ ++ return gcalloc (nmemb, size); ++} ++ ++void ++free (void *ptr) ++{ ++ gfree (ptr); ++} ++ ++void * ++aligned_alloc (size_t alignment, size_t size) ++{ ++ return galigned_alloc (alignment, size); ++} ++ ++void * ++realloc (void *ptr, size_t size) ++{ ++ return grealloc (ptr, size); ++} ++ + #ifdef GC_MCHECK + + /* Standard debugging hooks for `malloc'.
