summaryrefslogtreecommitdiffstats
path: root/lib/talloc/talloc.c
Commit message (Collapse)AuthorAgeFilesLines
* talloc: ensure the sibling linked list remains valid during a freeAndrew Tridgell2011-08-091-15/+3
| | | | | | | | | | | | This ensures that the sibling list of a pointer doesn't become invalid during a free operation. It is an alternative fix to the fix in 6f51a1f45bf4de062cce7a562477e8140630a53d, and avoids the problem of trying to calculate the parent pointer early This should fix the subtle spoolss talloc bug that Simo found Autobuild-User: Andrew Tridgell <tridge@samba.org> Autobuild-Date: Tue Aug 9 01:53:17 CEST 2011 on sn-devel-104
* talloc: preserve context name on talloc_free_children()Simo Sorce2011-07-291-0/+23
| | | | | | | Otherwise tc->name will end up pointing to garbage when it is not set to a const but rather to a string allocate as child of the context itself. Signed-off-by: Andrew Tridgell <tridge@samba.org>
* talloc: splitout _talloc_free_children_internal()Stefan Metzmacher2011-05-171-50/+27
| | | | | | | metze Autobuild-User: Stefan Metzmacher <metze@samba.org> Autobuild-Date: Tue May 17 10:49:13 CEST 2011 on sn-devel-104
* talloc: fixed a use after free error in talloc_free_children()Stefan Metzmacher2011-05-171-1/+16
| | | | | | This is similar to commit 6f51a1f45bf4de062cce7a562477e8140630a53d. metze
* talloc: use _talloc_free_internal() in talloc_free_children()Stefan Metzmacher2011-05-171-1/+1
| | | | metze
* talloc: setup the new 'tc' before TC_UNDEFINE_GROW_CHUNK() _talloc_realloc()Stefan Metzmacher2011-05-171-0/+1
| | | | metze
* talloc: make really sure only optimize realloc if there's only one pool chunkStefan Metzmacher2011-05-171-1/+6
| | | | | | | *talloc_pool_objectcount(pool_tc) == 2 doesn't mean the one of the objects is the pool itself! So we better check for == 1 and calculate the chunk count. metze
* talloc: make use of _talloc_free_poolmem() in _talloc_realloc()Stefan Metzmacher2011-05-171-15/+1
| | | | | | This should follow the same logic... metze
* talloc: split the handling of FLAG_POOL/FLAG_POOLMEM in _talloc_free_internalStefan Metzmacher2011-05-171-32/+66
| | | | | | | | | | | | | | | The optimization of the object_count == 1 case should only happen for when we're not destroying the pool itself. And it should only happen if the pool itself is still valid. If the pool isn't valid (it has TALLOC_FLAG_FREE), object_count == 1 does not mean that the pool is the last object, which can happen if you use talloc_steal/move() on memory from the pool and then free the pool itself. Thanks to Volker for noticing this! metze
* talloc: use TC_UNDEFINE_SHRINK_CHUNK() instead of ↵Stefan Metzmacher2011-05-021-1/+36
| | | | | | | | | | | | | | TC_INVALIDATE_SHRINK_CHUNK() for realloc path If we optimize on top of raw realloc() we need TC_INVALIDATE_SHRINK_CHUNK together with TC_UNDEFINE_GROW_CHUNK (with was missing and caused false positive valgrind warnings). But that is really slow, as we do a lot of talloc_realloc calls in samba. That's why we only to TC_UNDEFINE_SHRINK_CHUNK() for now. metze
* talloc: fix compiler warnings with -Wc++-compatStefan Metzmacher2011-04-131-5/+5
| | | | | | | metze Autobuild-User: Stefan Metzmacher <metze@samba.org> Autobuild-Date: Wed Apr 13 14:33:23 CEST 2011 on sn-devel-104
* talloc: include valgrind headers if availableStefan Metzmacher2011-04-081-0/+9
| | | | | | metze Signed-off-By: Andrew Tridgell <tridge@samba.org>
* talloc: add TC_INVALIDATE_POOL marcoStefan Metzmacher2011-04-081-3/+38
| | | | | | metze Signed-off-By: Andrew Tridgell <tridge@samba.org>
* talloc: add TC_UNDEFINE_GROW_CHUNK() marcoStefan Metzmacher2011-04-081-0/+21
| | | | | | metze Signed-off-By: Andrew Tridgell <tridge@samba.org>
* talloc: add TC_INVALIDATE_SHRINK_CHUNK() marcoStefan Metzmacher2011-04-081-0/+28
| | | | | | | | This invalidates the unused bytes if we shrink memory. metze Signed-off-By: Andrew Tridgell <tridge@samba.org>
* talloc: add TC_INVALIDATE_FULL_CHUNK() macroStefan Metzmacher2011-04-081-12/+36
| | | | | | | | | This makes it easier to mark a talloc pointer as invalid. metze Signed-off-By: Andrew Tridgell <tridge@samba.org>
* talloc: use VALGRIND_MAKE_MEM_UNDEFINED() before memmove()Stefan Metzmacher2011-04-081-0/+12
| | | | | | metze Signed-off-By: Andrew Tridgell <tridge@samba.org>
* talloc: optimize talloc_free() and talloc_realloc() for talloc poolsStefan Metzmacher2011-04-081-22/+138
| | | | | | metze Signed-off-By: Andrew Tridgell <tridge@samba.org>
* talloc: add TC_POOL_FIRST_CHUNK() macroStefan Metzmacher2011-04-081-2/+5
| | | | | | metze Signed-off-By: Andrew Tridgell <tridge@samba.org>
* talloc: add TC_POOL_SPACE_LEFT() macroStefan Metzmacher2011-04-081-2/+5
| | | | | | metze Signed-off-By: Andrew Tridgell <tridge@samba.org>
* talloc: add TC_ALIGN16() macroStefan Metzmacher2011-04-081-2/+3
| | | | | | metze Signed-off-By: Andrew Tridgell <tridge@samba.org>
* talloc: use TC_HDR_SIZE instead of sizeof(struct talloc_chunk)Stefan Metzmacher2011-04-081-1/+1
| | | | | | | | As this includes the padding to 16 bytes. metze Signed-off-By: Andrew Tridgell <tridge@samba.org>
* talloc: fixed a use after free errorAndrew Tridgell2011-01-051-1/+16
| | | | | | | | | | | this is the minimal fix for the problem Rusty found. I previously thought that the best fix would be to change tc->parent to be valid for all pointers, but that is expensive for realloc with large numbers of child pointers, which is much more commmon than I expected it to be. Autobuild-User: Andrew Tridgell <tridge@samba.org> Autobuild-Date: Wed Jan 5 07:22:27 CET 2011 on sn-devel-104
* talloc: Clarify error message on access after free.Jelmer Vernooij2011-01-051-4/+4
|
* talloc: added TALLOC_FREE_FILL environment variableAndrew Tridgell2010-11-191-0/+30
| | | | | | 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
* Move talloc_enable_null_tracking() to the s3 daemonsVolker Lendecke2010-10-081-7/+0
|
* talloc: fixed spelling errors in commentAndrew Tridgell2010-09-151-2/+2
|
* talloc: there is no ambiguity when freeing a ptr with a null parentAndrew Tridgell2010-04-201-0/+7
| | | | | | | | 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>
* talloc: mark public functions as _PUBLIC_Andrew Tridgell2010-04-181-62/+62
|
* talloc: a useful bit of debug codeAndrew Tridgell2010-04-021-0/+8
| | | | | this is useful when tracking down talloc loops. It is probably too expensive to have on by default.
* talloc: add a define for TALLOC_MAX_DEPTHAndrew Tridgell2010-04-021-1/+1
| | | | Thanks to the suggestion from simo
* talloc: limit the depth that talloc will go for talloc_is_parent()Andrew Tridgell2010-04-021-2/+11
| | | | | | 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()
* talloc: Fix write behind memory blockKamen Mazdrashki2009-12-081-1/+1
| | | | | | | 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>
* talloc: fixed talloc_disable_null_tracking()Andrew Tridgell2009-09-201-0/+27
| | | | | | | | | | | | 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
* talloc: don't crash if f is NULL in talloc_report_*Andrew Tridgell2009-09-171-2/+4
| | | | | | | 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.
* talloc: when we enable NULL tracking, reparent the autofree contextAndrew Tridgell2009-09-151-0/+3
| | | | | | | 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.
* report the location of the original talloc_free on double freetalloc-2.0.0Andrew Tridgell2009-09-041-11/+18
| | | | | | | | 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.
* talloc: add defines and functions for TALLOC_MAJOR/MINOR_VERSIONStefan Metzmacher2009-08-241-7/+39
| | | | | | | | | | 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
* talloc: remove ABI compat functionsStefan Metzmacher2009-08-241-28/+0
| | | | metze
* talloc: remove unused build dependecies to sambaStefan Metzmacher2009-08-241-18/+0
| | | | metze
* talloc: add talloc_set_log_fn() and talloc_set_log_stderr()Stefan Metzmacher2009-08-241-12/+49
| | | | | | | So that the application can setup a log function to get ERROR and WARNING messages. metze
* talloc: let talloc_steal() only generate a warning if it's used with referencesStefan Metzmacher2009-08-241-2/+1
| | | | | | We have to many callers, which rely on that talloc_steal() never fails. metze
* talloc: call return after abort, because an overloaded abort function might ↵Stefan Metzmacher2009-08-241-0/+4
| | | | | | | | | not exit This will be useful in the testsuite, where we could check if an abort would happen. metze
* talloc: report the size of reference handles as 0Stefan Metzmacher2009-08-241-1/+3
| | | | metze
* talloc: let talloc_total_blocks() and talloc_get_size() operate on the ↵Stefan Metzmacher2009-08-241-2/+15
| | | | | | null_context metze
* Fix some warningsVolker Lendecke2009-07-041-2/+3
|
* Restore ABI compatibility for talloc.Simo Sorce2009-07-031-4/+39
|
* talloc: change TALLOC_MAGIC for version 2.0.0Stefan Metzmacher2009-07-021-1/+12
| | | | metze
* a talloc_realloc() to zero size needs to use an unambiguous freeAndrew Tridgell2009-07-011-1/+1
|
* changes to remove the ambiguity in talloc_free() and talloc_steal() Andrew Tridgell2009-07-011-20/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.