src: add curl_global_init_mem testing

Build with "configure --enable-init-mem-debug" to make the tool use
curl_global_init_mem() and a set of private memory funtion callbacks for
libcurl's memory management.

Using this setup, memory mixups in tool code is more likely to cause
crashes and thus get discovered while running tests.

This curl_global_init_mem debug mode can only be done when building
libcurl shared (not static) and without debugging enabled - since it
needs to use the custom memory funtion callbacks.

Closes #21099
This commit is contained in:
Daniel Stenberg 2026-03-24 16:25:03 +01:00
parent 6041b9b11b
commit 59c11074cf
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 114 additions and 0 deletions

View file

@ -510,7 +510,13 @@ option(CURL_DISABLE_TYPECHECK "Disable curl_easy_setopt()/curl_easy_getinfo() ty
mark_as_advanced(CURL_DISABLE_TYPECHECK)
option(CURL_DISABLE_VERBOSE_STRINGS "Disable verbose strings" OFF)
mark_as_advanced(CURL_DISABLE_VERBOSE_STRINGS)
option(CURL_DEBUG_GLOBAL_MEM "Debug curl_global_init_mem" OFF)
mark_as_advanced(CURL_DEBUG_GLOBAL_MEM)
if(CURL_DEBUG_GLOBAL_MEM)
# Set it via the command-line to make it apply to the entire directory.
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "CURL_DEBUG_GLOBAL_MEM")
endif()
if(CURL_DISABLE_TYPECHECK)
# Set it via the command-line to make it apply to examples also.
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "CURL_DISABLE_TYPECHECK")