summaryrefslogtreecommitdiff
path: root/source/fitz/memento.c
AgeCommit message (Collapse)Author
2018-03-22Clean up windows ifdefs.Tor Andersson
_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.
2017-07-03Memento: pointer checking functions.Robin Watts
Add some helpful functions for doing quick checks on pointer validity. Use these in the reference counting functions.
2017-06-30Tweak Memento: make ref counting advance events.Robin Watts
2017-04-27Include required system headers.Tor Andersson
2017-04-27memento: Don't include unnecessary headers.Tor Andersson
2017-03-29Happy New Year!Sebastian Rasmussen
2017-01-09Be consistent in use of DEBUG/NDEBUG macros.Tor Andersson
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.
2016-11-05Fix Memento bug.Robin Watts
while (i >= 0) { ... i -= 4; } doesn't work well when i is unsigned.
2016-11-04Avoid warning in memento builds.Robin Watts
2016-11-03Memento: Silence MSVC warningsRobin Watts
For security and x64 builds.
2016-09-20Fix Memento crashRobin Watts
When reallocing set the rawsize before attempting to write the post guard block.
2016-09-20Sync Memento with gs.Robin Watts
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.
2016-09-17Squash some memento warnings in MEMENTO_LEAKONLY builds.Robin Watts
2016-09-14Update android logging code within Memento.Robin Watts
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.
2016-09-13Fix Memento Android backtrace code.Robin Watts
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.
2016-09-13Update Memento for Android.Robin Watts
Add backtrace abilities, and fix missing return value from android logging.
2016-07-08git stripspaceTor Andersson
2016-06-14Fix typos in various parts of the code.Sebastian Rasmussen
2016-03-28Memento: Add facility to cope with 'known' leaked blocks.Robin Watts
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.
2016-03-26Memento: Cope with wrapped blocks.Robin Watts
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.
2016-03-23Tweak Memento to avoid suprious valgrind warnings.Robin Watts
2016-03-15Memento: Avoid warnings building without HAVE_LIBDLRobin Watts
2016-03-15Memento: Rename memento 'globals' to 'memento'.Robin Watts
Neatness.
2016-03-15Memento: Add Memento_{takeRef,dropRef,reference} functions.Robin Watts
These work with MEMENTO_DETAILS to allow us to store the events where reference counts change.
2016-03-10Memento: Pull in latest fixes from gs.Robin Watts
2016-03-07Memento: List block details at closedown.Robin Watts
2016-03-07Memento: Store/display backtraces with blocks.Robin Watts
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.
2016-03-07Memento: Store callstacks for events.Robin Watts
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.
2016-03-03Memento: Speed improvements.Robin Watts
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.
2015-05-15Memento improvements.Robin Watts
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.
2015-02-25Add 64 bit windows builds to MSVC solution.Robin Watts
A few casts are required within the code, along with a few #ifdef changes. Some tweaks to curl are required too.
2014-01-17Fix more Memento/Valgrind interactions.Robin Watts
Seen when valgrinding a memento build of mudraw on: e0e44ed8692671b820de72c6c0a32608_asan_heap-uaf_8c2b76_1530_2026.pdf
2014-01-13Memento fixes for working with valgrind.Robin Watts
Remember to make blocks defined before writing/reading them.
2013-07-03Update Memento to output to debug window on windows.Robin Watts
Windows is stupid and doesn't display stderr/stdout in the debugger. Update Memento so that messages will appear there too.
2013-06-20Rearrange source files.Tor Andersson