|
From: <sv...@va...> - 2012-06-15 22:20:09
|
philippe 2012-06-15 23:19:59 +0100 (Fri, 15 Jun 2012)
New Revision: 12642
Log:
Fix 203877 and 301229 increase to 16Mb maximum allowed alignment for memalign() and posix_memalign
Note that VG_(arena_memalign) is not used by core or tools for the moment.
We have one single maxima for both the V core/tools and the client.
Enhanced memcheck/tests/memalign2.c to test 4 Mb and 16 Mb alignments.
Modified files:
trunk/NEWS
trunk/coregrind/m_mallocfree.c
trunk/memcheck/tests/memalign2.c
Modified: trunk/coregrind/m_mallocfree.c (+2 -1)
===================================================================
--- trunk/coregrind/m_mallocfree.c 2012-06-15 17:20:23 +01:00 (rev 12641)
+++ trunk/coregrind/m_mallocfree.c 2012-06-15 23:19:59 +01:00 (rev 12642)
@@ -1920,10 +1920,11 @@
// this allocation; it isn't optional.
vg_assert(cc);
+ // Check that the requested alignment has a plausible size.
// Check that the requested alignment seems reasonable; that is, is
// a power of 2.
if (req_alignB < VG_MIN_MALLOC_SZB
- || req_alignB > 1048576
+ || req_alignB > 16 * 1024 * 1024
|| VG_(log2)( req_alignB ) == -1 /* not a power of 2 */) {
VG_(printf)("VG_(arena_memalign)(%p, %lu, %lu)\n"
"bad alignment value %lu\n"
Modified: trunk/memcheck/tests/memalign2.c (+8 -4)
===================================================================
--- trunk/memcheck/tests/memalign2.c 2012-06-15 17:20:23 +01:00 (rev 12641)
+++ trunk/memcheck/tests/memalign2.c 2012-06-15 23:19:59 +01:00 (rev 12642)
@@ -76,6 +76,8 @@
p = memalign(4096, 100); assert(0 == (long)p % 4096);
p = memalign(4097, 100); assert(0 == (long)p % 8192);
+ p = memalign(4 * 1024 * 1024, 100); assert(0 == (long)p % 4 * 1024 * 1024);
+ p = memalign(16 * 1024 * 1024, 100); assert(0 == (long)p % 16 * 1024 * 1024);
# define PM(a,b,c) posix_memalign((void**)a, b, c)
@@ -88,15 +90,17 @@
assert(0 == res && 0 == (long)p % sizeof(void*));
res = PM(&p, 31, 100); assert(EINVAL == res);
- res = PM(&p, 32, 100); assert(0 == res &&
- 0 == (long)p % 32);
+ res = PM(&p, 32, 100); assert(0 == res && 0 == (long)p % 32);
res = PM(&p, 33, 100); assert(EINVAL == res);
res = PM(&p, 4095, 100); assert(EINVAL == res);
- res = PM(&p, 4096, 100); assert(0 == res &&
- 0 == (long)p % 4096);
+ res = PM(&p, 4096, 100); assert(0 == res && 0 == (long)p % 4096);
res = PM(&p, 4097, 100); assert(EINVAL == res);
+ res = PM(&p, 4 * 1024 * 1024, 100); assert(0 == res
+ && 0 == (long)p % 4 * 1024 * 1024);
+ res = PM(&p, 16 * 1024 * 1024, 100); assert(0 == res
+ && 0 == (long)p % 16 * 1024 * 1024);
# endif
return 0;
Modified: trunk/NEWS (+2 -0)
===================================================================
--- trunk/NEWS 2012-06-15 17:20:23 +01:00 (rev 12641)
+++ trunk/NEWS 2012-06-15 23:19:59 +01:00 (rev 12642)
@@ -70,6 +70,7 @@
where XXXXXX is the bug number as listed below.
197914 Building valgrind from svn now requires automake-1.10
+203877 increase to 16Mb maximum allowed alignment for memalign() and posix_memalign
219156 Valgrind does not handle statically linked malloc or other malloc lib (e.g. tcmalloc)
247386 make perf does not run all performance tests
270006 Valgrind scheduler unfair
@@ -109,6 +110,7 @@
n-i-bz Add missing gdbserver xml files for shadow registers for ppc32
n-i-bz Fix false positive in sys_clone on amd64 when optional args are not given (e.g. child_tidptr)
n-i-bz Fix assert in gdbserver for watchpoints watching the same address
+301229 dup of 203877, see above.
Release 3.7.0 (5 November 2011)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
From: Florian K. <br...@ac...> - 2012-06-15 22:34:33
|
> Modified: trunk/memcheck/tests/memalign2.c (+8 -4) > =================================================================== > --- trunk/memcheck/tests/memalign2.c 2012-06-15 17:20:23 +01:00 (rev 12641) > +++ trunk/memcheck/tests/memalign2.c 2012-06-15 23:19:59 +01:00 (rev 12642) > @@ -76,6 +76,8 @@ > p = memalign(4096, 100); assert(0 == (long)p % 4096); > p = memalign(4097, 100); assert(0 == (long)p % 8192); > > + p = memalign(4 * 1024 * 1024, 100); assert(0 == (long)p % 4 * 1024 * 1024); Shouldn't the assert be: assert(0 == (long)p % (4 * 1014 * 1024)) ? I believe all multiplicative operators have the same precedence and group left to right: 6.5.5 Multiplicative operators Syntax multiplicative-expression: cast-expression multiplicative-expression * cast-expression multiplicative-expression / cast-expression multiplicative-expression % cast-expression > + p = memalign(16 * 1024 * 1024, 100); assert(0 == (long)p % 16 * 1024 * 1024); likewise > > # define PM(a,b,c) posix_memalign((void**)a, b, c) > > @@ -88,15 +90,17 @@ > assert(0 == res && 0 == (long)p % sizeof(void*)); > > res = PM(&p, 31, 100); assert(EINVAL == res); > - res = PM(&p, 32, 100); assert(0 == res && > - 0 == (long)p % 32); > + res = PM(&p, 32, 100); assert(0 == res && 0 == (long)p % 32); > res = PM(&p, 33, 100); assert(EINVAL == res); > > res = PM(&p, 4095, 100); assert(EINVAL == res); > - res = PM(&p, 4096, 100); assert(0 == res && > - 0 == (long)p % 4096); > + res = PM(&p, 4096, 100); assert(0 == res && 0 == (long)p % 4096); > res = PM(&p, 4097, 100); assert(EINVAL == res); > > + res = PM(&p, 4 * 1024 * 1024, 100); assert(0 == res > + && 0 == (long)p % 4 * 1024 * 1024); > + res = PM(&p, 16 * 1024 * 1024, 100); assert(0 == res > + && 0 == (long)p % 16 * 1024 * 1024); likewise Florian |