[QUICK] talloc bugs
Sam Liddicott
sam at liddicott.com
Tue Jun 30 07:31:23 MDT 2009
* tridge wrote, On 30/06/09 05:57:
> > > First off I'd propose that for a test patch we abort() if you
> > > talloc_free() a pointer with a reference. Then we can run 'make test'
> > > and see just how often this happens. I think it will be very rare, and
> > > we may even find it doesn't happen at all outside of the talloc test
> > > suite.
> > >
> > I'll do that (just for you).
>
> thanks! I'll be very interested in the results.
>
>
The attached diff causes no tests to be run:
PROVISIONING DC...
A summary with detailed information can be found in:
/summary
ALL OK (0 tests in 0 testsuites)
Maybe I made what should be an obvious mistake, but I can't find it.
I'm still looking to see what is going on.
Sam
-------------- next part --------------
diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c
index 33cbfd7..634265c 100644
--- a/lib/talloc/talloc.c
+++ b/lib/talloc/talloc.c
@@ -971,6 +971,17 @@ void *talloc_named_const(const void *context, size_t size, const char *name)
*/
int talloc_free(void *ptr)
{
+ struct talloc_chunk *tc;
+
+ if (unlikely(ptr == NULL)) {
+ return -1;
+ }
+
+ tc = talloc_chunk_from_ptr(ptr);
+
+ if (unlikely(tc->refs)) {
+ abort();
+ }
return _talloc_free(ptr);
}
More information about the samba-technical
mailing list