1 |
chithanh 12/02/29 19:13:22 |
2 |
|
3 |
Added: gnash-0.8.10-jemalloc-aslr-fix.patch |
4 |
Log: |
5 |
Add patch to fix broken jemalloc, bug #405993. |
6 |
|
7 |
(Portage version: 2.2.0_alpha89/cvs/Linux x86_64) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 www-plugins/gnash/files/gnash-0.8.10-jemalloc-aslr-fix.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/www-plugins/gnash/files/gnash-0.8.10-jemalloc-aslr-fix.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/www-plugins/gnash/files/gnash-0.8.10-jemalloc-aslr-fix.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: gnash-0.8.10-jemalloc-aslr-fix.patch |
16 |
=================================================================== |
17 |
diff -Naur gnash-0.8.10.alt/libbase/jemalloc.c gnash-0.8.10/libbase/jemalloc.c |
18 |
--- gnash-0.8.10.alt/libbase/jemalloc.c 2012-02-07 09:39:41.000000000 +0100 |
19 |
+++ gnash-0.8.10/libbase/jemalloc.c 2012-02-24 18:36:47.000000000 +0100 |
20 |
@@ -429,7 +429,7 @@ |
21 |
static const bool __isthreaded = true; |
22 |
#endif |
23 |
|
24 |
-#if defined(MOZ_MEMORY_SOLARIS) && defined(MAP_ALIGN) && !defined(JEMALLOC_NEVER_USES_MAP_ALIGN) |
25 |
+#if defined(MOZ_MEMORY_SOLARIS) && defined(MAP_ALIGN) && !defined(JEMALLOC_NEVER_USES_MAP_ALIGN) || defined(MOZ_MEMORY_LINUX) |
26 |
#define JEMALLOC_USES_MAP_ALIGN /* Required on Solaris 10. Might improve performance elsewhere. */ |
27 |
#endif |
28 |
|
29 |
@@ -2238,6 +2238,7 @@ |
30 |
* We don't use MAP_FIXED here, because it can cause the *replacement* |
31 |
* of existing mappings, and we only want to create new mappings. |
32 |
*/ |
33 |
+#ifdef MOZ_MEMORY_SOLARIS |
34 |
#ifdef MALLOC_PAGEFILE |
35 |
if (pfd != -1) { |
36 |
ret = mmap((void *)alignment, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | |
37 |
@@ -2252,6 +2253,31 @@ |
38 |
|
39 |
if (ret == MAP_FAILED) |
40 |
ret = NULL; |
41 |
+#else /* !MOZ_MEMORY_SOLARIS */ |
42 |
+#ifdef MALLOC_PAGEFILE |
43 |
+ if (pfd != -1) { |
44 |
+ ret = mmap((void *)alignment, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | |
45 |
+ MAP_NOSYNC, pfd, 0); |
46 |
+ } else |
47 |
+#endif |
48 |
+ { |
49 |
+ ret = mmap(NULL, size + alignment, PROT_READ | PROT_WRITE, MAP_PRIVATE | |
50 |
+ MAP_NOSYNC | MAP_ANON, -1, 0); |
51 |
+ } |
52 |
+ assert(ret != NULL); |
53 |
+ |
54 |
+ if (ret == MAP_FAILED) |
55 |
+ return NULL; |
56 |
+ |
57 |
+ uintptr_t aligned_ret; |
58 |
+ size_t extra_size; |
59 |
+ aligned_ret = (uintptr_t)ret + alignment - 1; |
60 |
+ aligned_ret &= ~(alignment - 1); |
61 |
+ extra_size = aligned_ret - (uintptr_t)ret; |
62 |
+ munmap(ret, extra_size); |
63 |
+ munmap(ret + extra_size + size, alignment - extra_size); |
64 |
+ ret = (void*)aligned_ret; |
65 |
+#endif /* ifdef MOZ_MEMORY_SOLARIS*/ |
66 |
return (ret); |
67 |
} |
68 |
#endif |