From: Philippe Waroquiers Date: Fri, 15 Jun 2012 22:19:59 +0000 (+0000) Subject: Fix 203877 and 301229 increase to 16Mb maximum allowed alignment for memalign() and... X-Git-Tag: svn/VALGRIND_3_8_0~226 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e46d2abe7e23549b0ac52e98537d0640bff4a1bf;p=thirdparty%2Fvalgrind.git 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. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12642 --- diff --git a/NEWS b/NEWS index 7ed0f0b036..6681bf5967 100644 --- a/NEWS +++ b/NEWS @@ -70,6 +70,7 @@ https://bugs.kde.org/show_bug.cgi?id=XXXXXX 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 Bypass gcc4.4/4.5 wrong code generation causing out of memory or asserts 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) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/coregrind/m_mallocfree.c b/coregrind/m_mallocfree.c index 40c12f67d6..2eb7e9c18f 100644 --- a/coregrind/m_mallocfree.c +++ b/coregrind/m_mallocfree.c @@ -1920,10 +1920,11 @@ void* VG_(arena_memalign) ( ArenaId aid, HChar* cc, // 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" diff --git a/memcheck/tests/memalign2.c b/memcheck/tests/memalign2.c index 12aa047db1..bd478026f0 100644 --- a/memcheck/tests/memalign2.c +++ b/memcheck/tests/memalign2.c @@ -76,6 +76,8 @@ int main ( void ) 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 @@ int main ( void ) 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;