Package: valgrind Version: 1:3.3.1-2 Severity: important valgrind is incapable of debugging programs which use memalign(3) to allocate aligned memory blocks >= 2 MB in size:
[EMAIL PROTECTED]:~/code/test$ cat memalign.c
#include <stdlib.h>
#define size (1 << 21)
int main(void) {
void *ptr;
posix_memalign(&ptr, size, size);
free(ptr);
return 0;
}
[EMAIL PROTECTED]:~/code/test$ gcc -O0 -ggdb -Wall -o memalign memalign.c
[EMAIL PROTECTED]:~/code/test$ valgrind ./memalign
==31507== Memcheck, a memory error detector.
==31507== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==31507== Using LibVEX rev 1854, a library for dynamic binary translation.
==31507== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==31507== Using valgrind-3.3.1-Debian, a dynamic binary instrumentation
framework.
==31507== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==31507== For more details, rerun with: -v
==31507==
VG_(arena_memalign)(0x3879AB60, 2097152, 2097152)
bad alignment
valgrind: the 'impossible' happened:
VG_(arena_memalign)
==31507== at 0x380194CC: report_and_quit (m_libcassert.c:140)
==31507== by 0x380195E4: panic (m_libcassert.c:210)
==31507== by 0x38019652: vgPlain_core_panic_at (m_libcassert.c:215)
==31507== by 0x38019671: vgPlain_core_panic (m_libcassert.c:220)
==31507== by 0x380228BE: vgPlain_arena_memalign (m_mallocfree.c:1392)
==31507== by 0x38002909: vgMemCheck_new_block (mc_malloc_wrappers.c:195)
==31507== by 0x38002BEA: vgMemCheck_memalign (mc_malloc_wrappers.c:259)
==31507== by 0x38033F08: vgPlain_scheduler (scheduler.c:1277)
==31507== by 0x380448D3: run_a_thread_NORETURN (syswrap-linux.c:89)
sched status:
running_tid=1
Thread 1: status = VgTs_Runnable
==31507== at 0x4C1FFCF: memalign (vg_replace_malloc.c:460)
==31507== by 0x4C20068: posix_memalign (vg_replace_malloc.c:569)
==31507== by 0x400536: main (memalign.c:7)
Note: see also the FAQ.txt in the source distribution.
It contains workarounds to several common problems.
If that doesn't help, please report this bug to: www.valgrind.org
In the bug report, send all the above text, the valgrind
version, and what Linux distro you are using. Thanks.
[EMAIL PROTECTED]:~/code/test$
there is a check in coregrind/m_mallocfree.c:1385 which reads,
// Check that the requested alignment seems reasonable; that is, is
// a power of 2.
if (req_alignB < VG_MIN_MALLOC_SZB
|| req_alignB > 1048576
|| VG_(log2)( req_alignB ) == -1 /* not a power of 2 */) {
VG_(printf)("VG_(arena_memalign)(%p, %lu, %lu)\nbad alignment",
a, req_alignB, req_pszB );
VG_(core_panic)("VG_(arena_memalign)");
/*NOTREACHED*/
}
the comment or the code is wrong, as there are certainly powers of 2
larger than 1048576.
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.25-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages valgrind depends on:
ii libc6 2.7-12 GNU C Library: Shared libraries
Versions of packages valgrind recommends:
ii gdb 6.8-3 The GNU Debugger
-- no debconf information
--
Robert Edmonds
[EMAIL PROTECTED]
signature.asc
Description: Digital signature

