diff --git a/.github/workflows/experimental.yml b/.github/workflows/experimental.yml index 8ffb4b63c..bb945d598 100644 --- a/.github/workflows/experimental.yml +++ b/.github/workflows/experimental.yml @@ -52,7 +52,7 @@ jobs: env: ARCH: amd64 CMAKE_GENERATOR: Visual Studio 17 2022 - CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DEXPERIMENTAL_SHA256=ON + CMAKE_OPTIONS: -A x64 -DDEBUG_LEAK_CHECKER=win32 -DDEPRECATE_HARD=ON -DEXPERIMENTAL_SHA256=ON SKIP_SSH_TESTS: true SKIP_NEGOTIATE_TESTS: true # TODO: this is a temporary removal diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f6af730b1..90c02977e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -80,7 +80,7 @@ jobs: env: ARCH: amd64 CMAKE_GENERATOR: Visual Studio 17 2022 - CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_HTTPS=Schannel -DUSE_SSH=ON -DCMAKE_PREFIX_PATH=D:\Temp\libssh2 + CMAKE_OPTIONS: -A x64 -DDEBUG_LEAK_CHECKER=win32 -DDEPRECATE_HARD=ON -DUSE_HTTPS=Schannel -DUSE_SSH=ON -DCMAKE_PREFIX_PATH=D:\Temp\libssh2 BUILD_PATH: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin;D:\Temp\libssh2\bin BUILD_TEMP: D:\Temp SKIP_SSH_TESTS: true @@ -92,7 +92,7 @@ jobs: env: ARCH: x86 CMAKE_GENERATOR: Visual Studio 17 2022 - CMAKE_OPTIONS: -A Win32 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS -DUSE_BUNDLED_ZLIB=ON -DUSE_SSH=ON -DCMAKE_PREFIX_PATH=D:\Temp\libssh2 + CMAKE_OPTIONS: -A Win32 -DDEBUG_LEAK_CHECKER=win32 -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS -DUSE_BUNDLED_ZLIB=ON -DUSE_SSH=ON -DCMAKE_PREFIX_PATH=D:\Temp\libssh2 BUILD_PATH: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin;D:\Temp\libssh2\bin BUILD_TEMP: D:\Temp SKIP_SSH_TESTS: true diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index a12803d5b..852a3fb83 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -91,7 +91,7 @@ jobs: env: ARCH: amd64 CMAKE_GENERATOR: Visual Studio 17 2022 - CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_HTTPS=Schannel -DUSE_SSH=ON -DCMAKE_PREFIX_PATH=D:\Temp\libssh2 + CMAKE_OPTIONS: -A x64 -DDEBUG_LEAK_CHECKER=win32 -DDEPRECATE_HARD=ON -DUSE_HTTPS=Schannel -DUSE_SSH=ON -DCMAKE_PREFIX_PATH=D:\Temp\libssh2 BUILD_PATH: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin;D:\Temp\libssh2\bin BUILD_TEMP: D:\Temp SKIP_SSH_TESTS: true @@ -103,7 +103,7 @@ jobs: env: ARCH: x86 CMAKE_GENERATOR: Visual Studio 17 2022 - CMAKE_OPTIONS: -A Win32 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS -DUSE_BUNDLED_ZLIB=ON -DUSE_SSH=ON -DCMAKE_PREFIX_PATH=D:\Temp\libssh2 + CMAKE_OPTIONS: -A Win32 -DDEBUG_LEAK_CHECKER=win32 -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS -DUSE_BUNDLED_ZLIB=ON -DUSE_SSH=ON -DCMAKE_PREFIX_PATH=D:\Temp\libssh2 BUILD_PATH: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin;D:\Temp\libssh2\bin BUILD_TEMP: D:\Temp SKIP_SSH_TESTS: true @@ -370,7 +370,7 @@ jobs: env: ARCH: amd64 CMAKE_GENERATOR: Visual Studio 17 2022 - CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DEXPERIMENTAL_SHA256=ON + CMAKE_OPTIONS: -A x64 -DDEBUG_LEAK_CHECKER=win32 -DDEPRECATE_HARD=ON -DEXPERIMENTAL_SHA256=ON SKIP_SSH_TESTS: true SKIP_NEGOTIATE_TESTS: true # TODO: this is a temporary removal diff --git a/CMakeLists.txt b/CMakeLists.txt index 864f813ff..4e884db50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,7 @@ if(APPLE) endif() # Debugging options - set(DEBUG_LEAK_CHECKER "" CACHE STRING "Run tests with leak checker. Either valgrind or leaks.") + set(DEBUG_LEAK_CHECKER "" CACHE STRING "Configure for leak checking test runs. One of valgrind, leaks, or win32. Either valgrind or leaks.") option(USE_STANDALONE_FUZZERS "Enable standalone fuzzers (compatible with gcc)" OFF) option(DEBUG_POOL "Enable debug pool allocator" OFF) option(DEBUG_STRICT_ALLOC "Enable strict allocator behavior" OFF) @@ -78,9 +78,6 @@ if(MSVC) # If you want to embed a copy of libssh2 into libgit2, pass a # path to libssh2 option(EMBED_SSH_PATH "Path to libssh2 to embed (Windows)" OFF) - - # Enable leak checking using the debugging C runtime. - option(WIN32_LEAKCHECK "Enable leak reporting via crtdbg" OFF) endif() if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) diff --git a/cmake/DefaultCFlags.cmake b/cmake/DefaultCFlags.cmake index a9c9ab972..14899f89d 100644 --- a/cmake/DefaultCFlags.cmake +++ b/cmake/DefaultCFlags.cmake @@ -26,8 +26,8 @@ if(MSVC) set(CRT_FLAG_RELEASE "/MD") endif() - if(WIN32_LEAKCHECK) - set(GIT_WIN32_LEAKCHECK 1) + if(DEBUG_LEAK_CHECKER STREQUAL "win32") + set(GIT_DEBUG_LEAKCHECK_WIN32 1) set(CRT_FLAG_DEBUG "${CRT_FLAG_DEBUG}") set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} Dbghelp.lib") endif() diff --git a/src/util/alloc.c b/src/util/alloc.c index 998b0aea1..1059cb657 100644 --- a/src/util/alloc.c +++ b/src/util/alloc.c @@ -87,7 +87,7 @@ char *git__substrdup(const char *str, size_t n) static int setup_default_allocator(void) { -#if defined(GIT_WIN32_LEAKCHECK) +#if defined(GIT_DEBUG_LEAKCHECK_WIN32) return git_win32_leakcheck_init_allocator(&git__allocator); #elif defined(GIT_DEBUG_STRICT_ALLOC) return git_debugalloc_init_allocator(&git__allocator); diff --git a/src/util/allocators/win32_leakcheck.c b/src/util/allocators/win32_leakcheck.c index cdf16d348..f17f43271 100644 --- a/src/util/allocators/win32_leakcheck.c +++ b/src/util/allocators/win32_leakcheck.c @@ -7,7 +7,7 @@ #include "win32_leakcheck.h" -#if defined(GIT_WIN32_LEAKCHECK) +#if defined(GIT_DEBUG_LEAKCHECK_WIN32) #include "win32/w32_leakcheck.h" diff --git a/src/util/git2_features.h.in b/src/util/git2_features.h.in index b6eab6ed6..c2fa17eed 100644 --- a/src/util/git2_features.h.in +++ b/src/util/git2_features.h.in @@ -4,13 +4,12 @@ #cmakedefine GIT_DEBUG_POOL 1 #cmakedefine GIT_DEBUG_STRICT_ALLOC 1 #cmakedefine GIT_DEBUG_STRICT_OPEN 1 +#cmakedefine GIT_DEBUG_LEAKCHECK_WIN32 1 #cmakedefine GIT_THREADS 1 #cmakedefine GIT_THREADS_PTHREADS 1 #cmakedefine GIT_THREADS_WIN32 1 -#cmakedefine GIT_WIN32_LEAKCHECK 1 - #cmakedefine GIT_ARCH_64 1 #cmakedefine GIT_ARCH_32 1 diff --git a/src/util/win32/w32_leakcheck.c b/src/util/win32/w32_leakcheck.c index 0f095de12..26c20918c 100644 --- a/src/util/win32/w32_leakcheck.c +++ b/src/util/win32/w32_leakcheck.c @@ -7,7 +7,7 @@ #include "w32_leakcheck.h" -#if defined(GIT_WIN32_LEAKCHECK) +#if defined(GIT_DEBUG_LEAKCHECK_WIN32) #include "Windows.h" #include "Dbghelp.h" diff --git a/src/util/win32/w32_leakcheck.h b/src/util/win32/w32_leakcheck.h index 82d863851..52ff10a77 100644 --- a/src/util/win32/w32_leakcheck.h +++ b/src/util/win32/w32_leakcheck.h @@ -13,7 +13,7 @@ /* Initialize the win32 leak checking system. */ int git_win32_leakcheck_global_init(void); -#if defined(GIT_WIN32_LEAKCHECK) +#if defined(GIT_DEBUG_LEAKCHECK_WIN32) #include #include diff --git a/tests/clar/clar_libgit2_trace.c b/tests/clar/clar_libgit2_trace.c index 814a5fa9e..f33b019e1 100644 --- a/tests/clar/clar_libgit2_trace.c +++ b/tests/clar/clar_libgit2_trace.c @@ -164,7 +164,7 @@ static void _cl_trace_cb__event_handler( switch (ev) { case CL_TRACE__SUITE_BEGIN: git_trace(GIT_TRACE_TRACE, "\n\n%s\n%s: Begin Suite", HR, suite_name); -#if 0 && defined(GIT_WIN32_LEAKCHECK) +#if 0 && defined(GIT_DEBUG_LEAKCHECK_WIN32) git_win32__crtdbg_stacktrace__dump( GIT_WIN32__CRTDBG_STACKTRACE__SET_MARK, suite_name); @@ -172,7 +172,7 @@ static void _cl_trace_cb__event_handler( break; case CL_TRACE__SUITE_END: -#if 0 && defined(GIT_WIN32_LEAKCHECK) +#if 0 && defined(GIT_DEBUG_LEAKCHECK_WIN32) /* As an example of checkpointing, dump leaks within this suite. * This may generate false positives for things like the global * TLS error state and maybe the odb cache since they aren't diff --git a/tests/clar/main.c b/tests/clar/main.c index e3f4fe740..cdd463079 100644 --- a/tests/clar/main.c +++ b/tests/clar/main.c @@ -1,7 +1,7 @@ #include "clar_libgit2.h" #include "clar_libgit2_trace.h" -#ifdef GIT_WIN32_LEAKCHECK +#ifdef GIT_DEBUG_LEAKCHECK_WIN32 # include "win32/w32_leakcheck.h" #endif @@ -37,7 +37,7 @@ int main(int argc, char *argv[]) cl_global_trace_disable(); git_libgit2_shutdown(); -#ifdef GIT_WIN32_LEAKCHECK +#ifdef GIT_DEBUG_LEAKCHECK_WIN32 if (git_win32_leakcheck_has_leaks()) res = res || 1; #endif diff --git a/tests/libgit2/trace/windows/stacktrace.c b/tests/libgit2/trace/windows/stacktrace.c index 0a77ef99d..21dd13a48 100644 --- a/tests/libgit2/trace/windows/stacktrace.c +++ b/tests/libgit2/trace/windows/stacktrace.c @@ -1,7 +1,7 @@ #include "clar_libgit2.h" #include "win32/w32_leakcheck.h" -#if defined(GIT_WIN32_LEAKCHECK) +#if defined(GIT_DEBUG_LEAKCHECK_WIN32) static void a(void) { char buf[10000]; @@ -26,7 +26,7 @@ static void c(void) void test_trace_windows_stacktrace__basic(void) { -#if defined(GIT_WIN32_LEAKCHECK) +#if defined(GIT_DEBUG_LEAKCHECK_WIN32) c(); #endif } @@ -34,7 +34,7 @@ void test_trace_windows_stacktrace__basic(void) void test_trace_windows_stacktrace__leaks(void) { -#if defined(GIT_WIN32_LEAKCHECK) +#if defined(GIT_DEBUG_LEAKCHECK_WIN32) void * p1; void * p2; void * p3; @@ -124,7 +124,7 @@ void test_trace_windows_stacktrace__leaks(void) #endif } -#if defined(GIT_WIN32_LEAKCHECK) +#if defined(GIT_DEBUG_LEAKCHECK_WIN32) static void aux_cb_alloc__1(unsigned int *aux_id) { static unsigned int aux_counter = 0; @@ -141,7 +141,7 @@ static void aux_cb_lookup__1(unsigned int aux_id, char *aux_msg, size_t aux_msg_ void test_trace_windows_stacktrace__aux1(void) { -#if defined(GIT_WIN32_LEAKCHECK) +#if defined(GIT_DEBUG_LEAKCHECK_WIN32) git_win32_leakcheck_stack_set_aux_cb(aux_cb_alloc__1, aux_cb_lookup__1); c(); c();