Download Latest Version v102.zip (97.5 kB)
Email in envelope

Get an email when there's a new version of debug_new

Home / release / beta
Name Modified Size InfoDownloads / Week
Parent folder
v0.3.zip 2016-01-01 30.9 kB
v0.4.zip 2016-01-01 39.0 kB
RC1.zip 2016-01-01 49.7 kB
RC2.zip 2016-01-01 53.4 kB
README.txt 2016-01-01 22.7 kB
v0.1.zip 2016-01-01 22.3 kB
v0.2.zip 2016-01-01 22.3 kB
Totals: 7 Items   240.3 kB 0
***********************
*** version history ***
***********************


v100
  - Sorry, this one took so long, but I hard, to decide on salvaging this mess of
    a library, or to start it all over.
    I dicided on salvaging and make push a stable release, that 
  - First official, stable release!
  - Did a heck of a lot of refactoring and deprecations, to make debug_new more
    conforming with the c/c++ standard. (no more _*upper*... or __... identifiers)
  - All the old stuff is still available, if deprecations are enabled.
  - Notable changes:
    - __debug_*     --> DEBUG_NEW_API_*
    - _DEBUG_NEW_*  --> DEBUG_NEW_CONFIG_* / DEBUG_NEW_CONFIG_HAVE_*
    - __malloc_size --> malloc_msize
    - malloc_ex     --> mallocf // NOTE: Also added vmallocf and friends!
    NOTE: _OUT_OF_MEMORY didn't get renamed, but isn't used by debug_new.c any more!

  - New:
    -- MAJOR --
      - Added optimized allocation function, that can be used instead of malloc and friends:
        - *_nz  // The size parameter of the function may not be ZERO
        - *_nn  // The pointer parameter of the function may not be NULL
        - *_nnz // Both of the above (e.g.: realloc_nnz)
        - e.g.: malloc_nz
          - Can be used, if the size parameter of malloc isn't 0 (faster, than malloc)
      - Completed the API integration of strdup / wcsdup / mbsdup
        - All 3 dup-functions provide all possible combinations:
          >> {[strdup]} / {[_strdup]} / strndup
          >> {[wcsdup]} / {[_wcsdup]} / wcsndup
          >>   mbsdup   /  [_mbsdup]  / mbsndup
          NOTE: [] indicate function available in the native library of vc / vc++
          NOTE: {} indicate function available in the native library of gcc / g++
      - Removed dependency on _OUT_OF_MEMORY() from <debug_new.c>
        - Thus allowing _OUT_OF_MEMORY(), to call inlined code
        - Also makes it much easier, to set source-file specific behavior, and
          not have to worry about what debug_new itself will do with it!
      - Added the ability, to link debug_new statically (s.a.: "DEBUG_NEW_CONFIG_LINK_STATICALLY" in "debug_new_conf.inl")
      - Added allocation id and breakpoints on specific allocations:
        "__debug_alloc_breakpoint(n)" can be used, to break the application
        on the nth allocation call, thus making debugging of complicated, linear
        code easier (such as tests).
        (s.a.: "_DEBUG_NEW_WANT_ALLOC_ID" in "debug_new_conf.inl")
        (s.a.: "_DEBUG_NEW_WANT_BREAK_AT_ALLOC_ID" in "debug_new_conf.inl")
    -- MINOR --
      - Added a check for "DEBUG_NEW_WITHOUT_HEADERS", that can be set before
        #including <debug_new.h>, to manually handle headers
        (allows for substitution of library headers)
        NOTE: Also works with <debug_new.c>, when linking statically

    -- MINOR --
      - Added more names to the debug_throw macro detection
      - Added support for some gcc attributes

  - Removed:
    -- MINOR --
      - Removed most of the whole __debug_throw(...) mess (it was conflicting with too many libraries).
        Now its only using:
         - "__debug_throw(Expr)" as a hook for a debug-throw function
         - "__debug_rethrow"     as a hook for addition rethrow information to an exception
      - Deprecated "__realloc_new" (No way, of handling realloc() returning a NULL pointer)

  - Fixed:
    -- MINOR --
      - Some more re-factoring name bugs
      - Fixed a small bug, that may have previously caused _OUT_OF_MEMORY(),
        to throw the wrong exception in c++



RC2 (0.9.1)
  - New:
    -- MAJOR --
      - Full (tested) compatibility with pthread (and thereby posix platforms)
      - Added functionality to get the size of an allocated pointer.
        Only provided, if the native library already provides such a method.
        s.a.: "_DEBUG_NEW_HAVE___MALLOC_SIZE" in <debug_new_conf.inl>
        - Inconjunction, I added "__malloc_size", which is always available in debug
          and release mode, if the native library provides a method for getting the size
          of a malloc'ed pointer.
          Supported methods are:
           - [posix]   "malloc_usable_size"
           - [windows] "_msize"
           - [osx]     "malloc_size"
        - If present in the native library, these methods will be overwritten
          in debug-mode, as to ensure compatibility with existing code.
          Note, that these methods possibly being overwritten and "__malloc_size"
          being linked against debug_new can be temporarily disabled with the
          enable/disable functionality of debug_new
    -- MINOR --
      - Added more tests
      - Added compiler test scripts for
        - window/linux "gcc"
        - window/linux "g++"
  - Fixed:
    -- MAJOR --
      - Fixed an recursion error, where <debug_new_enable.inl>
        sometimes couldn't re-enable debug_new.
    -- MINOR --
      - Fixed some re-factoring bugs
      - Fixed failing debug_new init/quit assertion
      - Fixed #include of <exception> while debug_new was enabled

RC1 (0.9.0)
  - New:
    -- MAJOR --
      - [Re]Added file-out logging functionality to debug_new.
        s.a.: "_DEBUG_NEW_HAVE_LOG" in <debug_new_conf.inl>
      - Added handling for too big allocations:
        - Similar to "_DnHandle_OutOfMemory", but
          only triggered, if an allocation is soo big,
          it could never succeed.
        - s.a. "_DEBUG_NEW_TOO_BIG_ALLOC" in <debug_new_conf.inl>
      - Added support for non-MSC Windows compilers, do use
        "DebugBreak" from the windows api for breakpoints.
      - Added "DnDump_MostThreadAllocs" / "DnDump_MostGlobalAllocs",
        to dump sorted lists of allocation counts.
        s.a.: descr of "DnDump_MostThreadAllocs" in "debug_new.h"
      - Added disable / enable functionality:
        - Debug_new's hooks to non-debug functions can be disable
          and reenabled at any point the program.
        - Especially useful, when overwriting per-class "operator new":
          #include <debug_new_disable.inl>
          static void *Foo::operator new(size_t s) { ... }
          #include <debug_new_enable.inl>
        - Implementation:
          - Generator for disable/enable "__debug_new_enable_disable_gen.py"
          - The 2 files can be #included at any time, because they
            only use the preprocessor for their magic.
          - #include Recursion is provided to up to 25 successive include of
            <debug_new_disable.inl>, followed by <debug_new_enable.inl>
            - That limit can be changed in the generator for these files
          - The files can be #included without debug_new already being included
          - If debug_new is disabled, while the header is included,
            the global bindings to "new", "malloc", ... will not be linked,
            but become available, once <debug_new_enable.inl> is #included
          - While debug_new is disabled, "_DEBUG_NEW_DISABLED" is defined
    -- MINOR --
      - Added support for the original debug_new macro "DEBUG_NEW".
        (it's really just an overload for "__debug_new")
        s.a.: "DEBUG_NEW" in "debug_new.h"
      - Added size aproximations to all dumping methods,
        that somehow print a size.
        In conjunction, I added a const "_DEBUG_NEW_SIZE_APROX_THRESHOLD"
        in "debug_new.h", that can be used, to set a threshold for
        when that aproximation should be printed.
      - Added experimental Win32 HeapAlloc support for "__os_internal_malloc",
        when "_DEBUG_NEW_EXPERIMENTAL" is enabled.

  - Changed:
    -- MAJOR --
      - Moved all global vars into the "_DEBUG_NEW_LIMITED_API" region,
        because none of these are meant for direct use.
      - Renamed "conf.h" to "debug_new_conf.inl", to not use such a generic
        name on a global #include scope ("#include <conf.h>")
    -- MINOR --
      - Changed "_DEBUG_NEW_EXPERIMENTAL", to support 3 modes:
        disabled, enabled, enabled-in-tested-environments.
        (default mode is enabled-in-tested-environments)
        s.a.: "_DEBUG_NEW_EXPERIMENTAL" in <debug_new_conf.inl>

  - Fixed:
    -- MAJOR --
      - Fixed a bug, where creating a new thread-state ("mstate_push()")
        would result in a heap corruption, if the calling thread inherited
        a pointer from another thread.
    -- MINOR --
      - Fixed "_DnDebug_Malloc2" returning valid pointers
        for __very__ large allocation requests.
        e.g.: "void *p = malloc((size_t)-1)" returned a valid
              pointer before, that was __way__ to small
      - Fixed a bug, that caused "_DnHandle_OutOfMemory",
        to display its error messages incorrectly, when
        "_PRINTF_SIZE_T" is available.
      - Fixed "Dn_ReportAssertionFailed" only displaying
        the file on all access channels.
      - Fixed a config bug, with "_DEBUG_NEW_AUTO_INIT" and
        "_DEBUG_NEW_AUTO_GLOBAL_STATE", most notably, when
        using "_DEBUG_NEW_FASTCFG_LEAKFIX"



v0.4
  - New:
    -- MAJOR --
      - Added "_*_NoLock" versions for most methods,
        that will not lock associated mutexes
      - Added advanced allocation methods
        - s.a. "_DEBUG_NEW_ADVANCED_ALLOC" in "conf.h"
      - Reworked debug_new, to get rid of "os_api.h" and "os_api.c"
       --> 2 less files, bringing the whole thing down to 3 in total!
      - Added some memory allocation / deallocation helper macros
        - s.a. "_DEBUG_NEW_ALLOC_HELPERS" in "conf.h"
        - s.a. "_DEBUG_NEW_ALLOC_HELPERS" in "debug_new.h"
      - Added warning message for trying to free the NULL-pointer
        (got silently dropped previously)
        - s.a. "_DnHandle_FreeNULLPointer" in "debug_new.h" / "debug_new.c"
      - Added compiler switch, to allow "free(NULL)"
        (s.a. "_DEBUG_NEW_ALLOW_FREE_NULL" in "conf.h")
      - Added compiler switch, to allow "realloc(NULL,s)"
        (s.a. "_DEBUG_NEW_ALLOW_REALLOC_NULL" in "conf.h")
      - Added full support for pthread, by adding "_OS_TLS_*" macros for pthread.
        (pthread will always be used, when the windows api cannot be used, which
         should improve compatibility with non-windows compilers / platforms)
      - Added compiler switch, to disable the static version vars from being included
        in a release-mode app, when compiling with a crappy optimizer.
        (s.a. "_DEBUG_NEW_STATIC_VERINFO" in "conf.h")
    -- MINOR --
      - Added a simple memory-leak detector for debug_new itself,
        to prevent debug_new itself leaking stuff.
      - Added some more assertions and assertion messages, when debugging debug_new
      - Added support for "_ONE_SOURCE" compile configurations, where only 1
        source file is being compiled, that includes all other source files.
      - Added copyright information to "Dn_VersionStr" in "conf.h"
        (s.a. "_DEBUG_NEW_COPYRIGHT" in "conf.h")
      - Added support for "NDEBUG" being the actual standard indicator for
        not building in debug_mode ("_DEBUG" can still be used,
        to indicate the opposite)
        (Commented out by default, to not accidentally include debug
         informations in a release build. s.a. "conf.h" near the top)
      - Added safeguards to some more macros, to prevent compiler warnings
        upon redefinition (e.g. "_CRT_SECURE_NO_WARNINGS" in "conf.h")

  - Changed:
    -- MAJOR --
      - Changed the type of "Dn_AllocType_t" from "char" to "int",
        because "int" should always be faster!
      - Removed dependency in "bool", "true" and "false" keywords in c-mode.
        ("int","1" and "0" are now always used)
      - the "_DEBUG_NEW_OVERWRITE_NO_DEBUG_OPERATOR_APIS" switch in "conf.h"
        now defaults to "0", because inexperienced user may get confused, why
        some random std-behaviour isn't the same, because debug_new was
        do the memory allocations.
      - Made a whole bunch of (previously) internal printing
        methods public and added them to the header file
        (e.g. "DnPrint_FileAndLine")
      - Renamed limited-api methods "_DnDump_Leak" and "_DnDump_Free" to
        "_DnDump_InvalidLeak" and "_DnDump_InvalidFree",
        to prevent confusion about whether or not "_DnDump_Free" is
        a deallocation method and stuff like that... (hint: it is not)
    -- MINOR --
      - Increased spacing between config options, to improve readability
      - Reduced "_DEBUG_NEW_TAILCHECK" to 8, because most things
        should already be detectable with 8 bytes (sizeof(maxint_t) == 8)
      - Changed default state of "_DEBUG_NEW_FIX_LEAKS" to 0,
        to not destroy data, that might help, when debugging.
        (e.g.: a string didn't get deallocated and debug_new points
               you to your generic string allocator, but the memory
               used by the string is long gone and you don't know,
               what that string said...)

  - Fixed:
    -- MAJOR --
      - Fixed pushing global states always resulting in pushing an empty state
        (like the one for leak-on-shutdown)
      - Fixed a bug in "_DnDump_StateErrors" related to a logical error
        on my behalf about leaks and frees, when dumping them.
      - Fixed a bug in "DnThread_Flush", that caused random
        accession violations from accessing a freed pointer
      - Fixed "_DnDump_StateErrors" only working for thread-states
      - Fixed a race condition, where thread A could free the
        thread-info of thread B, before thread B could start
        using his thread-info
      - Fixed a whole bunch of problems related to
        keeping threads alive from each other
        (resulting in the removal of "DnThread_Flush")
      - Fixed "_Dn_Process" crashing, when an unaligned /
        invalid pointer is being processed.
      - Reworked some misleading documentations
      - renamed some type decls, to follow
      - Fixed some locking-orders, that may have resulted in
        some mutexes not being left properly
      - Fixed a bug in "_DnDump_Allocs", that may have caused
        access violations, when debugging debug_new
      - Fixed some incorrect and missing out-of-memory handling
        in internal methods for working with memory-states
      - Re-added "__NOVAL" (now named "__noval"), after learning that "((void)0)" actually is __STDC__.
        "__noval" is now used as a placeholder for all debug_new macros, when
        debugging is disabled (this fixes seamingly correct calls like
        "if (foo()) mstate_push(),x = 1;" in release mode)
      - Some fallback-macros, that return values, when debug_new is enable, didn't
        return values of the same type or at all, when debug_new is disabled.
        (the worst one probably being "__debug_check_ptr" not just returning 1, when not debugging)
    -- MINOR --
      - Added missing include to "<windows.h>" in "debug_new.c", required for "OutputDebugStringA"
      - Renamed the include guard for "conf.h" from "_DEBUG_NEW_CONF_C" to "_DEBUG_NEW_CONF_H"
      - Fixed a logical mutex error, where "DnThread_GetPrintFuncStackSize"
        would not lock the print stack of the associated thread.
      - Fixed some spelling mistakes
      - Some rare config combination, that resulted in
        some output messages missing their ending line-feed
        (most notably the internal object-dump method "__dump_object_at" (old name))
      - Fixed a bug, that is unlikely, to possibly have ever occurred:
        in c-mode, with stats, when a thread b is deallocating its first
        pointer, that got allocated by another thread a and the application
        runs out-of-memory, as thread b tries to allocate its statistics,
        an access-violation would have occurred. O_o
      - Merged "_STMT_STR" and "__STMT_STR" into 1 macro-safety block,
        to let the compiler warn you, if one of them is already defined!
      - Ups: The version control said, that version "0.3.0" was "1.3.0".
        That's obviously wrong. Fixed it and now (like it should), it says "0.4.0".

  - Removed:
    -- MAJOR --
      - Removed "_curr_code_addr()"
        --> all macro calls call proxy methods, that use "_ReturnAddress()"
        --> removed the "addr" param from all methods called by macros.
            These methods now simply act as proxy methods, to limited api
            methods with names of the format "_*2"
      - Removed "DnThread_Flush", because flushing dead threads is
        incorrect in a multithreaded environment.
        Instead, a thread will get deleted automatically, when is doesn't
        manage any data like "__debug_printfunc_push", "__debug_mstate_push"
        or just regular allocations.
    -- MINOR --
      - Removed "DnDump_file" from "debug_new.h".
        It was an unlinked external var, that should have already
        been removed in v0.3, when the custom-print-function
        interface got added.


v0.3
  - New:
    - Added version information + version control
    - Added macro "__debug_check_ptr" for checking an allocated pointer for errors
    - Done a lot of re-factoring, to change everything "mem_*" to "Dn_*"
      - "dn" standing for "debug new"
      - added deprecations for old names
    - Added + finished more documentation comments
    - Added an alternate method / macro for "DnAccess_GetFunc",
      when __HAVE_FUNC__ is not defined
    - C++: Added switch for overwriting of new / delete
           operators outside of debug mode (default is off)
           (s.a. "_DEBUG_NEW_OVERWRITE_NO_DEBUG_OPERATOR_APIS" in "conf.h")
    - Added compiler switch, to toggle the freeing of
      remaining leaks on shut-down
      (s.a. "_DEBUG_NEW_FREE_LEAKS_ON_SHUTDOWN" in "conf.h")
    - Added recursion to "_Dn_Init" and "_Dn_Quit"
      Calling "_Dn_Init" twice results in you having to
      call "_Dn_Quit" twice as well, in order to quit the
      deadlock debugger
      (s.h. "_DEBUG_NEW_HAVE_INIT_QUIT_RECURSION" in "conf.h")
    - "DnState_PopThread" and "DnState_PopGlobal" both return
      the total number of inconsistencies encountered, while
      popping the state.
    - Added compiler switch "_DEBUG_NEW_LIMITED_API":
      - Limits access to api components, that may change
        (s.a. "_DEBUG_NEW_LIMITED_API" in "conf.h")
    - Added a testing suite, to test debug_new's functionality
      - Added Visual Studio and tcc files, to compile the
        testing suite (but srsly, just build a c / c++
        executable with "debug_new.c", "os_api.c" and "test.c")
    - Extended the stats api, to allow for access
      to specific fields
    - Added print function interface, allowing for
      overwriting the print output of debug_new.
      - Useful, when building private snapshots, when you want
        to redirect memory errors into an external file.
  - Changed:
    - Renamed "conf.c" to "conf.h", because it's not a source file
    - Renamed all remaining macros for debug_memory_access
      from "_DEBUG_MEMORY_*" to "_DEBUG_NEW_*"
      - added deprecations for old names
      - Did so, to prevent name collisions in c
    - in c++ "_debug_new_internal_init" and "_debug_new_internal_quit"
      as well as their newer version "_Dn_InitInternal" and "_Dn_QuitInternal"
      all require the "_NS_DEBUG_NEW" prefix, when being called.
  - Fixes:
    - Fixed Frees being displayed as leaks in leak / free log
    - Debug_new outside of debug_mode
      - Fixed overwriting of new / delete operators
        outside of default mode optional (sry, it still used
        some remnants of debug_new's past)
      - Fixed compiler switches for building debug_new,
        when "_WANT_DEBUG_NEW" is disabled
      - Fixed NOVAL not defined, by removing it completely
    - Fixed the availability of "_WANT_DEBUG_PRINT" in "conf.h",
      to make it possible, to access the debug print methods,
      when debug_new is disabled
    - Fix compile + runtime errors, when _DEBUG_NEW_WITH_STATS was disabled
  - Removed:
    - removed "#pragma once" and "#pragma hdrstop"
      from all files, to prevent possible compiler warnings
    - removed the dbgprint functions from os_api,
      because they were unnecessary.

v0.2
  - New:
    - !!!Full support for C!!!
      - To integrate in your c project,
        see description of "_DEBUG_NEW_MAIN_HOOK_INIT" in "conf.c"
        or installation notes below
    - Added a hook, to intercept the main method for automatic
      initialization in c (s.a. "_DEBUG_NEW_MAIN_HOOK_INIT" in "conf.c").
    - Added an internal counter to the init and quit methods for debug_new,
      to prevent problems and leaks from initializing and
      quitting debug_new recursively.
  - Fixes:
    - Made the __FUNC__ access information optional, based on a
      compiler switch, because not all compilers support some kind
      of magic macro, that expands to the function name of
      the current scope (s.a. "__HAVE_FUNC__" in "conf.c").
    - Fixed a bug, that caused thread a not being able to free
      a pointer allocated with thread b.
    - Fixed some confusions related to me forgetting, that thread
      handles under windows have the same size in x86 and x64.
    - Fixed some method declarations from the header not matching
      the implementations in the source.
  - Changed:
    - changed all template methods to *real* methods, to allow
      for c compatibility


*** installation notes ***
c:
  "every/file/that/uses/malloc/realloc/calloc/or/free.c":
    """
     ...
     #include <debug_new.h> // former include that added allocation methods
     ...
    """
  or if your compiler supports some kind of standard include:
    "standard/include/file.c"
    """
     ...
     #include <debug_new.h>
     ...
    """


  "source/with/main.c":
    """
     #ifndef __cplusplus
     # define _DEBUG_NEW_MAIN_HOOK_INIT 1
     #endif // !__cplusplus

     ...

     #include <debug_new.h>

     ...

     int main(int argc, char* argv[]) {
      ...
     }
    """


c++:
  "every/file/that/uses/malloc/realloc/calloc/free/new/or/delete.c":
  """
   ...
   #include <debug_new.h>
   ...
  """
  or if your compiler supports some kind of standard include:
    "standard/include/file.c"
    """
     ...
     #include <debug_new.h>
     ...
    """
Source: README.txt, updated 2016-01-01