Age | Commit message (Collapse) | Author |
|
_WIN32 is always defined on windows (it means the WinAPI is available).
_WIN64 is also defined on 64-bit targets.
This means the test for defined(_WIN32) || defined(_WIN64) is redundant,
since if _WIN64 is defined, then _WIN32 is always also defined.
MSC_VER is only defined for MSVC, so split the ifdef sections in
include/fitz/system.h into separate MSVC and WIN32 parts so that
we can build with MinGW and other non-MSVC compilers on windows.
|
|
Add some helpful functions for doing quick checks on pointer validity.
Use these in the reference counting functions.
|
|
|
|
|
|
|
|
|
|
Only use NDEBUG as it's the one that most environments already set, so
is likely to lead to the least amount of confusion if compiling with a
custom build system.
|
|
while (i >= 0) { ... i -= 4; } doesn't work well when i is unsigned.
|
|
|
|
For security and x64 builds.
|
|
When reallocing set the rawsize before attempting to write
the post guard block.
|
|
Including: Bug 697134: Tweak MEMENTO_GS_HACKS inclusion.
Rather than rolling our own memset prototype in this case, use
the one that gs provides.
And, bug 697133: Fix typo in Memento.
Causing a significant slowdown. Thanks to George Burgess IV
for spotting this.
|
|
|
|
Work around the problems in that androids logging only works
in whole lines by buffering until we have one.
Also, androids logging goes to a circular buffer that loses
data when it overflows. Hack around this by adding a 1ms sleep
after every line output.
|
|
Thanks to Sebastian for pointing out that the demangling code
wants a malloced block, cos it might realloc it. Drop back to
the dumber version.
|
|
Add backtrace abilities, and fix missing return value from
android logging.
|
|
|
|
|
|
Harfbuzz allocates blocks that it keeps around as statics.
There are a finite number of these, and they are never freed
(at least not in the build we use). Having Memento report
them as leaks is a pain.
So we extend Memento so that we can label blocks as being
leaks, and thus never have to be bothered by them.
|
|
If another routine 'wraps' memento blocks (such as a chunk allocator
or the 'trace' allocator in mudraw), then the address passed to
Memento_label, Memento_takeRef etc, can be inside the block rather
than at the start of the block.
Update Memento to cope with this.
|
|
|
|
|
|
Neatness.
|
|
These work with MEMENTO_DETAILS to allow us to store the events where
reference counts change.
|
|
|
|
|
|
If built with MEMENTO_DETAILS (on by default), we store the
backtrace on every event that affects a block.
Memento_details(address) will display the events that affected
a block (typically malloc, {realloc}*, free), including the
backtrace at each point.
Windows and linux use different mechanisms for this. Windows
loads a DLL and calls windows specific functions - no extra
libraries are required.
Linux also loads a shared object (libbacktrace.so). This is not
present on all platforms, so on platforms where it is not available
we just get addresses. These can be converted using addr2line
(unless ASLR is enabled).
In order for linux to be able to load libbacktrace.so we link in
libdl. If this is not available, define HAVE_LIBDL=no when building
the memento target.
|
|
Add Memento_info(address) that will show the details of a block
(callstacks when it was allocatd, realloced, freed etc).
This works on MSVC and GNUC using two different methods.
|
|
Avoid searching the linked list of blocks in order to remove a
block by moving to a doubly linked list. This can be done
without increasing the amount of memory in use by making better
use of the 'parent' pointer that is only used when displaying
nested blocks.
Also store magic values in the 'child' and 'sibling' pointers
(again only used when displaying nested blocks) so that we
can quickly verify that a block is real before doing too much
with it.
Those changes drastically reduce the time required for
MEMENTO_LEAKONLY runs (now the same order of magnitude as non
memento runs).
Normal memento runs are still very slow when the numbers of
blocks increase due to the paranoid checking taking time.
To ameliorate this a bit, we try 2 other things.
Firstly, we optimise the searching of blocks by making use of
int aligned tests. This still doesn't make much difference.
Secondly, we introduce a new mechanism for the 'paranoia'
levels. If a negative number is given for the paranoia level
(say -n) then we first perform our overwrite checks after n events.
We next test after 2n events, then 4n, then 8n etc.
The new default paranoia level is set to be -1024.
This makes a huge difference, and brings normal memento runs
down to be comparable with debug runs.
|
|
Firstly, when displaying a list of nested blocks, don't suppress
outputting a block just because it contains a pointer to itself.
Various valgrind fixes from the gs version of memento.
Experimental C++ operators. See writeup in memento.h comments for
how to integrate.
|
|
A few casts are required within the code, along with a few #ifdef
changes.
Some tweaks to curl are required too.
|
|
Seen when valgrinding a memento build of mudraw on:
e0e44ed8692671b820de72c6c0a32608_asan_heap-uaf_8c2b76_1530_2026.pdf
|
|
Remember to make blocks defined before writing/reading them.
|
|
Windows is stupid and doesn't display stderr/stdout in the debugger.
Update Memento so that messages will appear there too.
|
|
|