|
From: <sv...@va...> - 2005-08-17 04:03:38
|
Author: njn
Date: 2005-08-17 05:03:31 +0100 (Wed, 17 Aug 2005)
New Revision: 4439
Log:
malloc_usable_size() was totally broken, crashing immediately.
I guess it's not very widely used :)
Added:
trunk/memcheck/tests/malloc_usable.c
trunk/memcheck/tests/malloc_usable.stderr.exp
trunk/memcheck/tests/malloc_usable.vgtest
Modified:
trunk/coregrind/m_mallocfree.c
trunk/coregrind/pub_core_mallocfree.h
trunk/coregrind/pub_core_replacemalloc.h
trunk/memcheck/tests/Makefile.am
Modified: trunk/coregrind/m_mallocfree.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_mallocfree.c 2005-08-17 02:44:43 UTC (rev 4438)
+++ trunk/coregrind/m_mallocfree.c 2005-08-17 04:03:31 UTC (rev 4439)
@@ -1197,7 +1197,7 @@
}
=20
=20
-SizeT VG_(arena_payload_szB) ( ArenaId aid, void* ptr )
+SizeT VG_(arena_payload_szB) ( ThreadId tid, ArenaId aid, void* ptr )
{
Arena* a =3D arenaId_to_ArenaP(aid);
Block* b =3D get_payload_block(a, ptr);
Modified: trunk/coregrind/pub_core_mallocfree.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/pub_core_mallocfree.h 2005-08-17 02:44:43 UTC (rev 44=
38)
+++ trunk/coregrind/pub_core_mallocfree.h 2005-08-17 04:03:31 UTC (rev 44=
39)
@@ -81,7 +81,7 @@
must be called before any of VG_(malloc) and friends are called. */
extern void VG_(set_client_malloc_redzone_szB) ( SizeT rz_szB );
=20
-extern SizeT VG_(arena_payload_szB) ( ArenaId aid, void* payload );
+extern SizeT VG_(arena_payload_szB) ( ThreadId tid, ArenaId aid, void* p=
);
=20
extern void VG_(sanity_check_malloc_all) ( void );
=20
Modified: trunk/coregrind/pub_core_replacemalloc.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/pub_core_replacemalloc.h 2005-08-17 02:44:43 UTC (rev=
4438)
+++ trunk/coregrind/pub_core_replacemalloc.h 2005-08-17 04:03:31 UTC (rev=
4439)
@@ -50,7 +50,7 @@
void (*tl___builtin_vec_delete)(ThreadId tid, void* p);
void* (*tl_realloc) (ThreadId tid, void* p, SizeT size);
=20
- SizeT (*arena_payload_szB) (ArenaId aid, void* payload);
+ SizeT (*arena_payload_szB) (ThreadId tid, ArenaId aid, void* pay=
load);
Bool clo_trace_malloc;
};
=20
Modified: trunk/memcheck/tests/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/memcheck/tests/Makefile.am 2005-08-17 02:44:43 UTC (rev 4438)
+++ trunk/memcheck/tests/Makefile.am 2005-08-17 04:03:31 UTC (rev 4439)
@@ -39,6 +39,7 @@
leak-tree.stderr.exp2 leak-tree.stderr.exp64 \
leak-regroot.vgtest leak-regroot.stderr.exp \
leakotron.vgtest leakotron.stdout.exp leakotron.stderr.exp \
+ malloc_usable.stderr.exp malloc_usable.vgtest \
malloc1.stderr.exp malloc1.vgtest \
malloc2.stderr.exp malloc2.vgtest \
malloc3.stderr.exp malloc3.stdout.exp malloc3.vgtest \
@@ -99,7 +100,7 @@
doublefree error_counts errs1 exitprog execve execve2 erringfds \
fprw fwrite hello inits inline \
leak-0 leak-cycle leak-tree leak-regroot leakotron \
- malloc1 malloc2 malloc3 manuel1 manuel2 manuel3 \
+ malloc_usable malloc1 malloc2 malloc3 manuel1 manuel2 manuel3 \
match-overrun \
memalign_test memalign2 memcmptest mempool mmaptest \
nanoleak new_nothrow \
Added: trunk/memcheck/tests/malloc_usable.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/memcheck/tests/malloc_usable.c 2005-08-17 02:44:43 UTC (rev 443=
8)
+++ trunk/memcheck/tests/malloc_usable.c 2005-08-17 04:03:31 UTC (rev 443=
9)
@@ -0,0 +1,12 @@
+#include <assert.h>
+#include <malloc.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+int main(void)
+{
+ // Since our allocations are in multiples of 8, 99 will round up to 1=
04.
+ int* x =3D malloc(99);
+ assert(104 =3D=3D malloc_usable_size(x));
+ return 0;
+}
Added: trunk/memcheck/tests/malloc_usable.stderr.exp
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Added: trunk/memcheck/tests/malloc_usable.vgtest
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/memcheck/tests/malloc_usable.vgtest 2005-08-17 02:44:43 UTC (re=
v 4438)
+++ trunk/memcheck/tests/malloc_usable.vgtest 2005-08-17 04:03:31 UTC (re=
v 4439)
@@ -0,0 +1,2 @@
+prog: malloc_usable
+vgopts: -q
|