Bug 187760 - valgrind: the 'impossible' happened: VG_(arena_memalign)
Summary: valgrind: the 'impossible' happened: VG_(arena_memalign)
Status: RESOLVED NOT A BUG
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: 3.5 SVN
Platform: Debian testing Linux
: NOR crash
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-21 03:25 UTC by indy2718
Modified: 2009-08-14 01:24 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description indy2718 2009-03-21 03:25:15 UTC
Linux thermal 2.6.29-rc8 #1 SMP Fri Mar 13 22:34:44 EDT 2009 x86_64 GNU/Linux

I have a multithreaded program.   When valgrind  is run, I get a crash:

x@thermal:/home/x/pt/src/main$ valgrind ./pt
==10484== Memcheck, a memory error detector.
==10484== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==10484== Using LibVEX rev 1888, a library for dynamic binary translation.
==10484== Copyright (C) 2004-2009, and GNU GPL'd, by OpenWorks LLP.
==10484== Using valgrind-3.5.0.SVN, a dynamic binary instrumentation framework.
==10484== Copyright (C) 2000-2009, and GNU GPL'd, by Julian Seward et al.
==10484== For more details, rerun with: -v
==10484== 
VG_(arena_memalign)(0x387E62B8, 8388608, 4096)
bad alignment
valgrind: the 'impossible' happened:
   VG_(arena_memalign)
==10484==    at 0x3802A64C: report_and_quit (m_libcassert.c:140)
==10484==    by 0x3802A764: panic (m_libcassert.c:215)
==10484==    by 0x3802A7D2: vgPlain_core_panic_at (m_libcassert.c:220)
==10484==    by 0x3802A7F1: vgPlain_core_panic (m_libcassert.c:225)
==10484==    by 0x380361BE: vgPlain_arena_memalign (m_mallocfree.c:1593)
==10484==    by 0x38002C64: vgMemCheck_new_block (mc_malloc_wrappers.c:198)
==10484==    by 0x38002F43: vgMemCheck_memalign (mc_malloc_wrappers.c:265)
==10484==    by 0x3804F2B0: vgPlain_scheduler (scheduler.c:1311)
==10484==    by 0x380698F0: run_a_thread_NORETURN (syswrap-linux.c:89)
==10484==    by 0x38069B1A: vgModuleLocal_start_thread_NORETURN (syswrap-linux.c:212)
==10484==    by 0x3809421D: ??? (in /usr/local/lib/valgrind/memcheck-amd64-linux)
==10484==    by 0xDEADBEEFDEADBEEE: ???
==10484==    by 0x100000001: ???
==10484==    by 0x3: ???
==10484==    by 0x5100001D5100001D: ???
==10484==    by 0x380AF9C1: typeOfIRExpr (irdefs.c:1933)
==10484==    by 0x5000000C3899F418: ???
==10484==    by 0x380BD6D2: doAMode_M (hdefs.c:2061)
==10484==    by 0x3899F3A0: ???
==10484==    by 0x389A0CC0: ???
==10484==    by 0x389A0CD8: ???
==10484==    by 0x40768FC82: ???
==10484==    by 0x40768FD10: ???
==10484==    by 0x380BFE1E: emit_AMD64Instr (hdefs.c:2735)
==10484==    by 0x523899B580: ???
==10484==    by 0x3899B580: ???
==10484==    by 0xB: ???
==10484==    by 0x40768FC80: ???
==10484==    by 0x40768FD10: ???
==10484==    by 0x1FA: ???
==10484==    by 0x240: ???
==10484==    by 0x13: ???
==10484==    by 0x38172E3E: ??? (in /usr/local/lib/valgrind/memcheck-amd64-linux)
==10484==    by 0x38098F00: myvprintf_str (m_debuglog.c:467)


other threads ....
Comment 1 Nicholas Nethercote 2009-04-15 01:41:30 UTC
I think you've mixed up the order of the arguments to memalign.  The alignment is given by the first arg, the size by the second.  Valgrind is aborting because 8388608 is an inappropriate alignment value.  I've improved the error message to make this clearer.
Comment 2 Alex Ivershen 2009-08-14 00:10:10 UTC
Julian,

I ran into the exact same problem, and the arguments to memalign are correct. The particular application has to allocate 8MB-aligned memory segments for DMA to a disk array, and 8M alignment is perfectly appropriate. I modified the source code to check for 8M instead and everything worked.

Suggesting increasing the value to 8388608 in the trunk source code.
Thanks!
/ Alex Ivershen
Comment 3 Nicholas Nethercote 2009-08-14 01:24:07 UTC
Alex, can you please open a new bug with a title something like "increase maximum allowed alignment for memalign()".  Thanks.