A possible debugging improvement to talloc ...
Richard Sharpe
realrichardsharpe at gmail.com
Sat Feb 13 21:36:57 UTC 2016
Hi folks,
When I was chasing down a memory problem recently, I noticed that
there is some spare bytes in the talloc_chunk that could contain
another pointer, and thought this would be interesting:
[rsharpe at sharpe tarballs]$ diff -u talloc-2.1.1/talloc.c
talloc-2.1.1-mod/talloc.c
--- talloc-2.1.1/talloc.c 2016-02-13 13:34:47.266100765 -0800
+++ talloc-2.1.1-mod/talloc.c 2016-02-11 18:00:18.858928133 -0800
@@ -273,6 +273,8 @@
* from.
*/
struct talloc_pool_hdr *pool;
+
+ const char *stolen_loc;
};
/* 16 byte alignment seems to keep everyone happy */
@@ -850,7 +852,7 @@
return handle->ptr;
}
-static void *_talloc_steal_internal(const void *new_ctx, const void *ptr);
+static void *_talloc_steal_internal(const void *new_ctx, const void
*ptr, const char *location);
static inline void _talloc_free_poolmem(struct talloc_chunk *tc,
const char *location)
@@ -1067,7 +1069,7 @@
ptr on success, or NULL if it could not be transferred.
passing NULL as ptr will always return NULL with no side effects.
*/
-static void *_talloc_steal_internal(const void *new_ctx, const void *ptr)
+static void *_talloc_steal_internal(const void *new_ctx, const void
*ptr, const char *location)
{
struct talloc_chunk *tc, *new_tc;
size_t ctx_size = 0;
@@ -1082,6 +1084,11 @@
tc = talloc_chunk_from_ptr(ptr);
+ /* Stamp the name regardless */
+ if (location) {
+ tc->stolen_loc = location;
+ }
+
There's more ... if it looks useful I will clean it up and post it out.
--
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)
More information about the samba-technical
mailing list