1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-14 19:24:43 +03:00

30 Commits

Author SHA1 Message Date
Andrew Tridgell
999f3ed2ce talloc: added TALLOC_FREE_FILL environment variable
when this environment variable is set, talloc will fill freed memory
with the value from that environment variable. This can be used to
help find use after free bugs when valgrind is too slow to be used
2010-11-19 15:17:42 +11:00
Volker Lendecke
b5ed09c3af Move talloc_enable_null_tracking() to the s3 daemons 2010-10-08 21:11:45 +02:00
Andrew Tridgell
ba2c394ed4 talloc: fixed spelling errors in comment 2010-09-15 15:39:34 +10:00
Andrew Tridgell
45be1c7ba4 talloc: there is no ambiguity when freeing a ptr with a null parent
when a ptr has a single reference and a NULL parent, then
talloc_free(ptr) is not ambiguous, as the caller could not have done a
talloc_free(NULL) to free the memory

Pair-Programmed-With: Rusty Russell <rusty@samba.org>
2010-04-20 15:50:27 +10:00
Andrew Tridgell
ef496e8d1d talloc: mark public functions as _PUBLIC_ 2010-04-18 15:00:37 +10:00
Andrew Tridgell
fde50c633f talloc: a useful bit of debug code
this is useful when tracking down talloc loops. It is probably too
expensive to have on by default.
2010-04-02 18:52:29 +11:00
Andrew Tridgell
1b4bbec523 talloc: add a define for TALLOC_MAX_DEPTH
Thanks to the suggestion from simo
2010-04-02 18:52:29 +11:00
Andrew Tridgell
ff2b7d42e6 talloc: limit the depth that talloc will go for talloc_is_parent()
We have a bug in the dcerpc registry code that can cause a talloc loop
that chews unlimited CPU because of talloc_is_parent() during a
talloc_free()
2010-04-02 13:15:18 +11:00
Kamen Mazdrashki
8efabcc8a5 talloc: Fix write behind memory block
If ALWASY_REALLOC is defined and we are to 'shrink' memory block,
memcpy() will write outside memory just allocated.

Signed-off-by: Andrew Tridgell <tridge@samba.org>
2009-12-08 12:39:10 +11:00
Andrew Tridgell
3c5d763962 talloc: fixed talloc_disable_null_tracking()
When we disable null tracking, we need to move any existing objects
that are under the null_context to be parented by the true NULL
context.

We also need a new talloc_enable_null_tracking_no_autofree() function,
as the talloc testsuite cannot cope with the moving of the autofree
context under the null_context as it wants to check exact counts of
objects under the null_context, and smbtorture has a large number of
objects in the autofree_context from .init functions
2009-09-20 13:14:40 -07:00
Andrew Tridgell
78338d431c talloc: don't crash if f is NULL in talloc_report_*
It's annoying when you use 
  p talloc_report_full(ctx, fopen("/tmp/xx","w"))
in gdb, and if you don't have write permission on the file then
you get a segv.
2009-09-17 21:52:28 -07:00
Andrew Tridgell
00fb6705ff talloc: when we enable NULL tracking, reparent the autofree context
If NULL tracking is enabled after the autofree context is initialised
then autofree ends up separate from the null_context. This means that
talloc_report_full() doesn't report the autofree context. Fix this by
reparenting the autofree context when we create the null_context.
2009-09-15 18:45:41 -07:00
Andrew Tridgell
27b19eb9f6 report the location of the original talloc_free on double free
When we get a double free abort from talloc it is often hard to work
out where the first free came from. This patch takes advantage of the
fact that _talloc_free() now takes a location the free was called from
to allow the double free abort code to print the location of the first
free that conflicts.
2009-09-04 14:40:51 +10:00
Stefan Metzmacher
6c9ace27c5 talloc: add defines and functions for TALLOC_MAJOR/MINOR_VERSION
We also use the major and minor versions in the TALLOC_MAGIC,
so that we can detect if two conflicting versions of talloc
are loaded in one process. In this case we use talloc_log() to
output a very useful debug message before we call
talloc_abort().

metze
2009-08-24 16:29:58 +10:00
Stefan Metzmacher
5760edeeb6 talloc: remove ABI compat functions
metze
2009-08-24 16:29:58 +10:00
Stefan Metzmacher
8a90c8bc98 talloc: remove unused build dependecies to samba
metze
2009-08-24 16:29:58 +10:00
Stefan Metzmacher
e40f3144f2 talloc: add talloc_set_log_fn() and talloc_set_log_stderr()
So that the application can setup a log function to get ERROR
and WARNING messages.

metze
2009-08-24 16:29:58 +10:00
Stefan Metzmacher
ac8aeec824 talloc: let talloc_steal() only generate a warning if it's used with references
We have to many callers, which rely on that talloc_steal() never fails.

metze
2009-08-24 16:29:57 +10:00
Stefan Metzmacher
1fbc86c57a talloc: call return after abort, because an overloaded abort function might not exit
This will be useful in the testsuite,
where we could check if an abort would happen.

metze
2009-08-24 16:29:57 +10:00
Stefan Metzmacher
2c664db749 talloc: report the size of reference handles as 0
metze
2009-08-24 16:29:57 +10:00
Stefan Metzmacher
d1895d2fee talloc: let talloc_total_blocks() and talloc_get_size() operate on the null_context
metze
2009-08-24 16:29:57 +10:00
Volker Lendecke
5742ed128d Fix some warnings 2009-07-04 12:54:22 +02:00
Simo Sorce
2738178d13 Restore ABI compatibility for talloc. 2009-07-03 08:45:29 -04:00
Stefan Metzmacher
f1dbd58a99 talloc: change TALLOC_MAGIC for version 2.0.0
metze
2009-07-02 23:18:42 +10:00
Andrew Tridgell
3c2f4df555 a talloc_realloc() to zero size needs to use an unambiguous free 2009-07-01 16:37:33 +10:00
Andrew Tridgell
5fe1d8dc12 changes to remove the ambiguity in talloc_free() and talloc_steal()
These changes follow from the discussions on samba-technical. The
changes are in several parts, and stem from the inherent ambiguity
that was in talloc_free() and talloc_steal() when the pointer that is
being changes has more than one parent, via references.

The changes are:

 1) when you call talloc_free() on a pointer with more than one parent
 the free will fail, and talloc will log an error to stderr like this:

    ERROR: talloc_free with references at some/foo.c:123
	   reference at other/bar.c:201
	   reference at other/foobar.c:641
 
 2) Similarly, when you call talloc_steal() on a pointer with more
 than one parent, the steal will fail and talloc will log an error to
 stderr like this:

    ERROR: talloc_steal with references at some/foo.c:123
	   reference at other/bar.c:201

 3) A new function talloc_reparent() has been added to change a parent
 in a controlled fashion. You need to supply both the old parent and
 the new parent. It handles the case whether either the old parent was
 a normal parent or a reference

The use of stderr in the logging is ugly (and potentially dangerous),
and will be removed in a future patch. We'll need to add a debug
registration function to talloc.
2009-07-01 15:15:37 +10:00
Simo Sorce
b029e0edcf Prevent reallocs of the talloc pool itself 2009-04-22 09:58:06 -04:00
Stefan Metzmacher
7a8b97ec2b talloc: add talloc_set_abort_fn()
metze
2009-03-12 12:04:31 +01:00
Stefan Metzmacher
b6f479d441 talloc: add talloc_get_type_abort()
metze
2009-03-03 18:07:33 +01:00
Jelmer Vernooij
94855cd692 Move common libraries from root to lib/. 2008-09-17 14:11:12 +02:00