| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
| |
In case an external thread calls into our code and logs messages, a thread
object is allocated that will never be released. Even if we try to clean
up the object via thread value destructor there is no guarantee that the
thread actually terminates before we check for leaks, which seems to be the
case for the Ada Tasking threads.
|
| |
|
|
|
|
|
|
| |
Some of these are pretty broad, so maybe an alternative option is to
not use the soup plugin in the openssl-ikev2/rw-suite-b* scenarios. But
the plugin is not tested anywhere else so lets go with this for now.
|
| |
|
|
|
|
|
|
|
|
| |
If a function we whitelist allocates memory while leak detective is enabled
but only frees it after LD has already been disabled, free() will get called
with invalid pointers (not pointing to the actually allocated memory by LD),
which will cause checks in the C library to fail and the program to crash.
This tries to detect such cases and calling free with the correct pointer.
|
|
|
|
|
|
|
|
|
| |
Lots of static data is allocated in this function, which isn't freed until
the library is unloaded (we can't call OPENSSL_cleanup() as initialization
would fail when calling it again later). When enabling the leak
detective the test runner eventually crashes as all the data allocated during
initialization has an invalid size when freed after leak detective has been
unloaded.
|
|
|
|
|
|
|
|
| |
Newer versions of GCC are too "smart" and replace a call to malloc(X)
followed by a call to memset(0,X) with a call co calloc(), which obviously
results in an infinite loop when it does that in our own calloc()
implementation. Using `volatile` for the variable storing the total size
prevents the optimization and we actually call malloc().
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
This prevented `stroke memusage` from reporting the leaks on the
console. Instead, they were sent to the callbacks set up by libstrongswan.
Fixes a426851f6362 ("leak-detective: Use callback functions to report
leaks and usage information").
|
|
|
|
|
|
| |
gcry_check_version() does not free statically allocated resources. However,
we can't whitelist it in some versions, as it is not a resolvable symbol name.
Instead, whitelist our own plugin constructor function.
|
|
|
|
|
| |
This function is called by libcurl initialization with SSL, and uses
a static allocation of compression algorithms not freed.
|
|
|
|
|
| |
Include some more basic system headers in utils.h, so we can use that common
header on the different platforms.
|
|
|
|
|
| |
If lib->leak_detective is non-null some code parts (e.g. the plugin
loader) assume LD is actually used.
|
|
|
|
|
| |
For some utils _GNU_SOURCE might be needed but that conflicts with the
signature of strerror_r(3).
|
| |
|
|
|
|
|
|
|
| |
If realloc return a pointer value different from the value to be
reallocated, a double free can occur in this context.
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
|
|
|
|
|
| |
On OS X Mavericks, these functions use a static allocation and are hard
to whitelist using other means.
|
|
|
|
|
| |
If we initialize libstrongswan more than once in the same process, we may
not register the hooks twice.
|
|
|
|
| |
This resets leak detective state should it get created/destroyed more than once.
|
|
|
|
| |
This is more flexible than printing reports to a FILE.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
The only user (bfd backtraces) is fine with that, and we really should not
mess the enable flag while doing allocations with other threads.
|
|
|
|
|
| |
As we don't want to hold the lock, we must make sure backtraces keep valid
while printing them.
|
|
|
|
|
|
|
| |
If realloc moves an allocation, the original allocation gets freed. We
therefore must remove the hdr from the list, as it is invalid. We can add it
afterwards once it has been updated, allowing us to unlock the list during
reallocation.
|
|
|
|
|
|
|
| |
Some static allocations in plugins won't get freed, because in the test case
process the plugins are not destroyed. If a plugin would clean up allocations
done while just using the plugin, these show up as leak in the child process,
letting tests fail.
|
|
|
|
|
|
|
|
|
| |
If uses of dlopen(), e.g. when loading plugins, produce errors an error
string could get allocated dynamically. At this point realloc() might not
yet be resolved and when dlsym() is later called by leak detective to do
so the error string might get freed while leak detective is disabled and
real_free() will be called with a pointer into one of leak detective's
memory blocks instead of a pointer to the block itself, causing a SIGSEGV.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
tzset() is hard to whitelist on some systems, as there is no symbol involved.
Call tzset() explicitly before initialization to avoid false positives.
|
|
|
|
|
|
|
| |
malloc hooks have become deprecated, and their use has always been problematic,
especially in multi-threaded applications. Replace the functionality by
overriding all malloc functions and query the system allocator functions
using dlsym() with RTLD_NEXT.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
While the thread specific strerror buffer gets cleaned up for
worker threads during their termination, the main thread itself,
and so its strerror buffer, is still alive during leak reports.
|
| |
|
| |
|
| |
|