|
From: Jeremy F. <je...@go...> - 2003-04-02 08:42:36
|
This patch fixes the alignment of allocated memory when running under Valgrind but on the real CPU (for example, when you use --stop-after). http://www.goop.org/~jeremy/valgrind/87-malloc-align.patch coregrind/vg_clientfuncs.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletion(-) diff -puN coregrind/vg_clientfuncs.c~87-malloc-align coregrind/vg_clientfuncs.c --- valgrind/coregrind/vg_clientfuncs.c~87-malloc-align Sat Mar 15 19:02:57 2003 +++ valgrind-jeremy/coregrind/vg_clientfuncs.c Sat Mar 15 19:02:57 2003 @@ -102,7 +102,11 @@ void* malloc ( Int n ) if (VG_(running_on_simd_CPU)) { v = (void*)SIMPLE_REQUEST1(VG_USERREQ__MALLOC, n); } else { - v = VG_(arena_malloc)(VG_AR_CLIENT, n); + if (VG_(clo_alignment) == 4) + v = VG_(arena_malloc)(VG_AR_CLIENT, n); + else + v = VG_(arena_malloc_aligned)(VG_AR_CLIENT, + VG_(clo_alignment), n); } } if (VG_(clo_trace_malloc)) _ |
|
From: Nicholas N. <n.n...@gm...> - 2009-02-03 00:06:43
|
Hi, The VG_MIN_MALLOC_SZB constant defines the minimum size of a malloc'd block, and also its minimum alignment. Currently its value is 8. However, glibc uses the following minimum sizes/alignments: - 32-bit machines: 8 - 64-bit machines: 16 And Darwin always uses 16. Should we make this #define platform-specific? Nick |
|
From: Nicholas N. <n.n...@gm...> - 2009-02-03 11:20:18
|
[sending again... the first attempt didn't seem to get through] ---------- Forwarded message ---------- From: Nicholas Nethercote <n.n...@gm...> Date: Tue, Feb 3, 2009 at 11:06 AM Subject: malloc alignment To: Valgrind Developers <val...@li...> Hi, The VG_MIN_MALLOC_SZB constant defines the minimum size of a malloc'd block, and also its minimum alignment. Currently its value is 8. However, glibc uses the following minimum sizes/alignments: - 32-bit machines: 8 - 64-bit machines: 16 And Darwin always uses 16. Should we make this #define platform-specific? Nick |
|
From: Julian S. <js...@ac...> - 2003-04-02 20:14:33
|
Thx. Any enthusiasm for doing __builtin_new, __builtin_vec_new, realloc (all obvious) and calloc (no obvious corresponding fix ...) ? When I gather up a bit more steam I might do the others. J On Wednesday 02 April 2003 8:42 am, Jeremy Fitzhardinge wrote: > This patch fixes the alignment of allocated memory when running under > Valgrind but on the real CPU (for example, when you use --stop-after). > > > http://www.goop.org/~jeremy/valgrind/87-malloc-align.patch > > coregrind/vg_clientfuncs.c | 6 +++++- > 1 files changed, 5 insertions(+), 1 deletion(-) > > diff -puN coregrind/vg_clientfuncs.c~87-malloc-align > coregrind/vg_clientfuncs.c --- > valgrind/coregrind/vg_clientfuncs.c~87-malloc-align Sat Mar 15 19:02:57 > 2003 +++ valgrind-jeremy/coregrind/vg_clientfuncs.c Sat Mar 15 19:02:57 > 2003 @@ -102,7 +102,11 @@ void* malloc ( Int n ) > if (VG_(running_on_simd_CPU)) { > v = (void*)SIMPLE_REQUEST1(VG_USERREQ__MALLOC, n); > } else { > - v = VG_(arena_malloc)(VG_AR_CLIENT, n); > + if (VG_(clo_alignment) == 4) > + v = VG_(arena_malloc)(VG_AR_CLIENT, n); > + else > + v = VG_(arena_malloc_aligned)(VG_AR_CLIENT, > + VG_(clo_alignment), n); > } > } > if (VG_(clo_trace_malloc)) > > _ |