aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'emacs/24.5/07_all_gmalloc.patch')
-rw-r--r--emacs/24.5/07_all_gmalloc.patch81
1 files changed, 81 insertions, 0 deletions
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 <wjenkner@inode.at>
+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'.