Age | Commit message (Collapse) | Author | Files | Lines |
|
zeroed memory
(This used to be commit 65b7316e9b4589b02a8bd94150ccbfe526f6d159)
|
|
so talloc now doesn't contain any ldb specific functions.
allow NULL to be passed to a couple more talloc() functions
(This used to be commit 1246f80d806fb5f63cfbf3879de6d546384552a8)
|
|
which is much clearer and simpler to use. It removes a specific parent
from a pointer, no matter whether that parent is a "reference" or a
direct parent. This gives complete control over the free process.
(This used to be commit 6c563887f1b9b8c842309a523e88b6f2a32db10f)
|
|
(This used to be commit 06c58ad221ec40e46310e847ebf640bd53e8e468)
|
|
the % coverage in terms of lines of code of a test suite. I thought a
good first place to start with gcov was the talloc test suite. When I
started the test suite covered about 60% of all lines of code in
talloc.c, and now it covers about 99%. The only lines not covered are
talloc corruption errors, as that would cause smb_panic() to fire.
It will be interesting to try gcov on the main Samba test suite for
smbd. We won't achieve 100% coverage, but it would be nice to get to
90% or more.
I also modified the talloc.c sources to be able to be build standalone, using:
gcc -c -D_STANDALONE_ -Iinlcude lib/talloc.c
that should make it much easier to re-use talloc in other projects
(This used to be commit 8d4dc99b82efdf24b6811851c7bdd4af5a4c52c9)
|
|
- made the LOCAL-TALLOC smbtorture test much stricter, checking that
block counts for every pointer are correct after every operation
(This used to be commit 18d3e2647f0bedbba699d1ba2649c0cfe4526ef6)
|
|
might not place the pointer in the context specified in the docs. The
code was assuming that pointer was at the head of the child list,
which it may not be, depending on what other operations have happened
in between.
(This used to be commit e62bd7ef7ec80365ab00ce5b2051b7dc1726304b)
|
|
- added documentation for talloc_unreference()
- made the abandoned child logic in talloc_free() clearer and more consistent
(This used to be commit a87584c8e3fb06cd3ff29a918f681b5c6c32b9ff)
|
|
The problem was that the simple "uint_t ref_count;" in a talloc chunk
did not give enough information. It told us that a pointer was
referenced more than once, but it didn't say who it was referenced
by. This means that when the pointer was freed we had no sane way to
clean up the reference.
I have now replaced ref_count with a "refs" list, which means that
references point to the pointer, and the pointer has a linked list of
references. So now we can cleanup from either direction without losing track of anything.
I've also added a LOCAL-TALLOC smbtorture test that tests talloc
behaviour for some common uses.
(This used to be commit 911a8d590cb184bcb892810729955c2c4cf02550)
|
|
circular references (circular references are allowed, they just need
to be handled carefully inside talloc)
- mark talloc_reference() pointers nicely in the --leak-report-full
code, so you see what has a reference to what in a useful manner
(This used to be commit a87d3d11344069284604a7294a54cadcc6e1a096)
|
|
void *talloc_reference(const void *context, const void *ptr);
this function makes a secondary reference to ptr, and hangs it off the
given context. This greatly simplifies some of the current reference
counting code in the samr server and I suspect it will be widely used
in other places too.
the way you use it is like this:
domain_state->connect_state = talloc_reference(domain_state, connect_state);
that makes the element connect_state of domain_state a secondary
reference to connect_state. The connect_state structure will then only
be freed when both domain_state and the original connect_state go
away, allowing you to free them independently and in any order.
you could do this alrady using a talloc destructor, and that is what
the samr server did previously, but that meant this construct was
being reinvented in several places. So this convenience function sets
up the destructor for you, giving a much more convenient and less
error prone API.
(This used to be commit dc5315086156644fad093cbe6b02d999adba8540)
|
|
a const pointer really means that "the data pointed to by this pointer
won't change", and that is certainly true of talloc(). The fact that
some behind-the-scenes meta-data can change doesn't matter from the
point of view of const.
this fixes a number of const warnings caused by const data structures
being passed as talloc contexts. That will no longer generate a
warning.
also changed the talloc leak reporting option from --leak-check to
--leak-report, as all it does is generate a report on exit. A new
--leak-report-full option has been added that shows the complete tree
of memory allocations, which is is quite useful in tracking things down.
NOTE: I find it quite useful to insert talloc_report_full(ptr, stderr)
calls at strategic points in the code while debugging memory
allocation problems, particularly before freeing a major context (such
as the connection context). This allows you to see if that context has
been accumulating too much data, such as per-request data, which
should have been freed when the request finished.
(This used to be commit c60ff99c3129c26a9204bac1c6e5fb386114a923)
|
|
taking a context (so when you pass a NULL pointer you end up with
memory in a top level context). Fixed it by changing the API to take a
context. The context is only used if the pointer you are reallocing is
NULL.
(This used to be commit 8dc23821c9f54b2f13049b5e608a0cafb81aa540)
|
|
(This used to be commit 00518201754dc2de583267071ebd2adecbadcb59)
|
|
- talloc_strdup() and related functions get automatic names
(This used to be commit 0cf427d14fe0a19cb3e85b6191be220f3d81080a)
|
|
to get auto-naming of pointers very cheaply.
- fixed a couple of memory leaks found with the new tricks
A typical exit report for smbd is now:
talloc report on 'null_context' (total 811 bytes in 54 blocks)
auth/auth_sam.c:334 contains 20 bytes in 1 blocks
struct auth_serversupplied_info contains 498 bytes in 33 blocks
UNNAMED contains 8 bytes in 1 blocks
lib/data_blob.c:40 contains 16 bytes in 1 blocks
iconv(CP850,UTF8) contains 61 bytes in 4 blocks
iconv(UTF8,CP850) contains 61 bytes in 4 blocks
iconv(UTF8,UTF-16LE) contains 67 bytes in 4 blocks
iconv(UTF-16LE,UTF8) contains 67 bytes in 4 blocks
UNNAMED contains 13 bytes in 1 blocks
which is much better than before
(This used to be commit 6e721393d03afd3c2f8ced8422533547a9e33342)
|
|
auto-derived from the type you are allocating. This is done with
basically zero overhead by relying on the stringify operator in cpp
producing string constants.
the result is that --leak-check nicely names all pointers that come
from talloc_p()
(This used to be commit bd86ebe2972af4d424df20db1e422919aa6203d0)
|
|
and can't properly handle leaks of doubly linked lists which we use a
lot (as the memory is always reachable). Even with --show-reachable
its hard to track leaks down sometimes.
I realised that talloc does have the necessary information to track
these, and by using the cascading property of the new talloc it can
report on leaks in a much more succinct fashion than valgrind can.
I have added a new samba option --leak-check that applies to all Samba
tools. When enabled it prints a leak report summarising all top level
contexts that are present when the program exits. A typical report
looks like this:
talloc report on 'null_context' (total 1071 bytes in 52 blocks)
iconv(CP850,UTF8) contains 43 bytes in 3 blocks
UNNAMED contains 24 bytes in 1 blocks
UNNAMED contains 24 bytes in 1 blocks
dcesrv_init contains 604 bytes in 26 blocks
server_service contains 120 bytes in 6 blocks
UNNAMED contains 24 bytes in 1 blocks
UNNAMED contains 24 bytes in 1 blocks
server_service contains 104 bytes in 4 blocks
server_context contains 12 bytes in 2 blocks
iconv(UTF8,UTF-16LE) contains 46 bytes in 3 blocks
iconv(UTF-16LE,UTF8) contains 46 bytes in 3 blocks
the numbers are recursive summaries for all the memory hanging off each context.
this option is not thread safe when used, but the code is thread safe
if the option is not given, so I don't think thats a problem.
(This used to be commit 96d33d36a5639e7fc46b14a470ccac674d87c62a)
|
|
Andrew Bartlett
(This used to be commit 1640272dc36a0cb5bc8e647d06c7cee46022f077)
|
|
(This used to be commit a3a15f9d1a3b51cb7099b5f3adb8401dfc37793d)
|
|
--enable-developer warning for when they are missing.
Andrew Bartlett
(This used to be commit 8115e44d47bcd65edba08d10117180ae508cdbc1)
|
|
this means you can do:
talloc_set_destructor(ptr, my_destructor);
and your destructor will be called with the pointer as an argument
when the pointer is about to be freed. The destructor can refuse the
free by returning -1.
You can also increase the reference count on a pointer like this:
talloc_increase_ref_count(ptr);
and a talloc_free() will just reduce the reference count, only
actually freeing the memory when the count reaches zero.
(This used to be commit b5608d52d33a1d8be5a8a6751bc6cec162c7ed92)
|
|
it can only indicate programmer error, and doing a smb_panic() ensures
an automatic backtrace (and eventually an abort()).
Andrew Bartlett
(This used to be commit b2d93d0010d80f158760f53273853de2439c3062)
|
|
(This used to be commit 6ffdfd779936ce8c5ca49c5f444e8da2bbeee0a8)
|
|
This version does the following:
1) talloc_free(), talloc_realloc() and talloc_steal() lose their
(redundent) first arguments
2) you can use _any_ talloc pointer as a talloc context to allocate
more memory. This allows you to create complex data structures
where the top level structure is the logical parent of the next
level down, and those are the parents of the level below
that. Then destroy either the lot with a single talloc_free() or
destroy any sub-part with a talloc_free() of that part
3) you can name any pointer. Use talloc_named() which is just like
talloc() but takes the printf style name argument as well as the
parent context and the size.
The whole thing ends up being a very simple piece of code, although
some of the pointer walking gets hairy.
So far, I'm just using the new talloc() like the old one. The next
step is to actually take advantage of the new interface
properly. Expect some new commits soon that simplify some common
coding styles in samba4 by using the new talloc().
(This used to be commit e35bb094c52e550b3105dd1638d8d90de71d854f)
|
|
(This used to be commit d721b122b5c443363b8f8ec2e1ef4b798378b658)
|
|
team meeting at CIFS04. It allows you to find the talloc context given
any pointer allocated with talloc.
(This used to be commit 01dc4ed9b4f9390930d3c235cf2ccf9a9028392d)
|
|
- NULL in, NULL out
Andrew Bartlett
(This used to be commit 2cc0b3a2f1785c53268f018999a87c26539fd4a6)
|
|
just a alloc_asprintf().
(makes it easier to use in a loop)
Andrew Bartlett
(This used to be commit 5816d09c47252d2ee8732722b3cc44ea865b8fcc)
|
|
(This used to be commit 363cb3377a0eca5bfef71a02dcdc21c5fadbaf32)
|
|
metze
(This used to be commit 57151e80eb1090281401930c8fe25b20a8cf3a38)
|
|
talloc_free() O(1) in preparation. This also halves the number of
malloc() calls and increases our internal consistency checking,
without breaking valgrind testing.
(This used to be commit 2331d4e76e40ff08215853f747f7063213ac92ce)
|
|
(This used to be commit 20458556017f426ab57ca9a9d098cacecefbdcff)
|
|
implements the epm_Lookup() call, I'll add the other important calls
soon. I was rather pleased to find that epm_Lookup() worked first
time, which is particularly surprising given its complexity.
This required quite a bit of new infrastructure:
* a generic way of handling dcerpc policy handles in the rpc server
* added type checked varients of talloc. These are much less error
prone. I'd like to move to using these for nearly all uses of
talloc.
* added more dcerpc fault handling code, and translation from
NTSTATUS to a dcerpc fault code
* added data_blob_talloc_zero() for allocating an initially zero
blob
* added a endpoint enumeration hook in the dcerpc endpoint server
operations
(This used to be commit 3f85f9b782dc17417baf1ca557fcae22f5b6a83a)
|
|
(This used to be commit b0510b5428b3461aeb9bbe3cc95f62fc73e2b97f)
|