Skip to content

build: merge TrackMemory (CURLDEBUG) into debug-enabled option#20331

Closed
vszakats wants to merge 29 commits intocurl:masterfrom
vszakats:onedebug
Closed

build: merge TrackMemory (CURLDEBUG) into debug-enabled option#20331
vszakats wants to merge 29 commits intocurl:masterfrom
vszakats:onedebug

Conversation

@vszakats
Copy link
Member

@vszakats vszakats commented Jan 15, 2026

Drop separate TrackMemory (aka CURLDEBUG) debug feature.

After recent changes (thread-safety,
193cb00, and updates leading up to
it), TrackMemory is unlikely to cause build or runtime issues.

To simplify builds and debug options, enable TrackMemory
unconditionally for debug-enabled (aka DEBUGBUILD) builds. Before
this patch, this was already the default, with an option to disable
it, or enable it in non-debug-enabled builds.

Note, in practice these two debug options already went hand in hand. It
was not possible to toggle them separately for a long time due to bugs,
before 59dc9f7 (2024-05-28) fixed it.

This patch also removes/deprecates separate knobs and feature flags for
TrackMemory:

  • autotools: --enable-curldebug/--disable-curldebug
  • cmake: -DENABLE_CURLDEBUG=ON/OFF
  • C macro: CURLDEBUG
  • libcurl: CURL_VERSION_CURLDEBUG symbol deprecated in favor
    of CURL_VERSION_DEBUG. They always return the same value after this
    patch.

Also:

  • drop TrackMemory from curl -V output.
  • rename internal CURLDEBUG macro to CURL_MEMDEBUG internally.
    To avoid confusion with DEBUGBUILD, but to keep guarding
    TrackMemory-related internals for readability.
  • runtests: bind TrackMemory to debug feature. Keep it a separate
    test feature requirement, for clarity.
  • CI: drop test builds for combinations of the two options.
  • GHA/linux: no longer disable TrackMemory in the TSAN job.

Ref: #20328 (comment)


  • Perhaps keep accepting --enable-curldebug/--disable-curldebug as a no-op.
    For compatibility. → No need, by default there is just a warning shown. Only --enable-option-checking=fatal makes it an error.

@vszakats vszakats added the tests label Jan 15, 2026
@github-actions github-actions bot added cmdline tool libcurl API CI Continuous Integration labels Jan 15, 2026
@vszakats vszakats added the feature-window A merge of this requires an open feature window label Jan 15, 2026
@bagder
Copy link
Member

bagder commented Jan 15, 2026

rename CURLDEBUG macro to CURL_DEBUG_LEAK internally.

No, please don't!

  1. It's been CURLDEBUG for decades. I am so used to this.
  2. It is being used for debugging much more than just leaks

@vszakats
Copy link
Member Author

vszakats commented Jan 15, 2026

rename CURLDEBUG macro to CURL_DEBUG_LEAK internally.

No, please don't!

  1. It's been CURLDEBUG for decades. I am so used to this.
  2. It is being used for debugging much more than just leaks

I'm confused, what else does it do? It's controlling the memtrack
thing, with all wrappers inside memdebug.c. It has a total of 21
uses in the code, also enabling a CURL_MEMDEBUG env. These
uses are seldom touched in practice. What am I missing??

(we can name it anything, again, I just don't see why this is critical,
besides the old name causing confusion all the time.)

@bagder
Copy link
Member

bagder commented Jan 15, 2026

I'm confused, what else does it do?

#ifdef DEBUGBUILD
#define DEBUGF(x) x
#undef DEBUGASSERT
#ifdef DEBUGBUILD
#define DEBUGASSERT(x) assert(x)

@vszakats
Copy link
Member Author

I'm confused, what else does it do?

#ifdef DEBUGBUILD
#define DEBUGF(x) x
#undef DEBUGASSERT
#ifdef DEBUGBUILD
#define DEBUGASSERT(x) assert(x)

That is DEBUGBUILD. This patch does change nothing with it.

@bagder
Copy link
Member

bagder commented Jan 15, 2026

That is DEBUGBUILD. This patch does change nothing with it.

Then I am confused now.

What is this PR doing? I thought it made two defines into one, and then rename that single one?

@vszakats
Copy link
Member Author

vszakats commented Jan 15, 2026

That is DEBUGBUILD. This patch does change nothing with it.

Then I am confused now.

What is this PR doing? I thought it made two defines into one, and then rename that single one?

Ah OK, sorry! It keeps DEBUGBUILD as it is. Makes former CURLDEBUG an
internal macro with a new name CURL_DEBUG_LEAK, and makes it unconditionally
enabled whenever DEBUGBUILD is enabled.

The only reason to keep it internally under a separate macro, is to help us locate
the memtrack bits with grep. But they are enabled/disabled in sync, together.

It also merges the 'TrackMemory' feature into 'Debug' in build tooling and -V
output. They can't be toggled separately. Debug-enabled builds always feature
TrackMemory.

@bagder
Copy link
Member

bagder commented Jan 15, 2026

It keeps DEBUGBUILD as it is. Makes former CURLDEBUG an internal macro with a new name CURL_DEBUG_LEAK

Why do we need more than one define if they are in sync?

@vszakats
Copy link
Member Author

vszakats commented Jan 15, 2026

It keeps DEBUGBUILD as it is. Makes former CURLDEBUG an internal macro with a new name CURL_DEBUG_LEAK

Why do we need more than one define if they are in sync?

Because TrackMemory is a distinct feature internally, and
I think it's useful to be able to locate its moving parts when
working on the code. It's only 21 places, so has little/no "cost".
It's basically an interim macro used for readability.
We do that in other places.

@bagder
Copy link
Member

bagder commented Jan 15, 2026

So a CURL_MEMDEBUG perhaps? That's already the name of the environment variable that controls it.

@vszakats
Copy link
Member Author

vszakats commented Jan 15, 2026

So a CURL_MEMDEBUG perhaps? That's already the name of the environment variable that controls it.

Yes, works for me. Will push it shortly.

edit: GH seems to have an ongoing CI job status refresh issue.

@vszakats vszakats changed the title debug: integrate CURLDEBUG into DEBUGBUILD build: merge CURLDEBUG option into DEBUGBUILD Jan 15, 2026
@vszakats vszakats requested a review from Copilot January 15, 2026 19:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request merges the separate CURLDEBUG (TrackMemory) option into DEBUGBUILD, making memory tracking always enabled in debug builds. The main purpose is to simplify the build configuration by eliminating the separate toggle for memory debugging features.

Changes:

  • Removed the CURLDEBUG conditional compilation flag from all Makefiles and build systems
  • Renamed the internal CURLDEBUG macro to CURL_MEMDEBUG throughout the codebase for clarity
  • Deprecated the public CURL_VERSION_CURLDEBUG flag and removed TrackMemory from feature lists

Reviewed changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/unit/Makefile.am Removed CURLDEBUG conditional compilation flag
tests/tunit/Makefile.am Removed CURLDEBUG conditional compilation flag
tests/runtests.pl Updated TrackMemory detection to use Debug feature instead
tests/libtest/first.c Renamed CURLDEBUG to CURL_MEMDEBUG
tests/libtest/Makefile.am Removed CURLDEBUG conditional compilation flag
src/tool_main.c Renamed CURLDEBUG to CURL_MEMDEBUG
src/tool_libinfo.c Removed TrackMemory from feature list
src/curlinfo.c Renamed CURLDEBUG to CURL_MEMDEBUG
src/curl.rc Removed CURLDEBUG from debug flags check
src/Makefile.am Removed CURLDEBUG conditional compilation flag
projects/OS400/curl.inc.in Marked CURL_VERSION_CURLDEBUG as deprecated
m4/curl-confopts.m4 Removed CURL_CHECK_OPTION_CURLDEBUG macro definition
lib/version.c Removed TrackMemory feature entry
lib/memdebug.c Renamed CURLDEBUG to CURL_MEMDEBUG
lib/libcurl.rc Removed CURLDEBUG from debug flags check
lib/fake_addrinfo.h Renamed CURLDEBUG to CURL_MEMDEBUG
lib/curlx/fopen.h Renamed CURLDEBUG to CURL_MEMDEBUG
lib/curlx/fopen.c Renamed CURLDEBUG to CURL_MEMDEBUG
lib/curl_setup.h Added CURL_MEMDEBUG definition when DEBUGBUILD is set and renamed all CURLDEBUG references
lib/curl_addrinfo.h Renamed CURLDEBUG to CURL_MEMDEBUG
lib/curl_addrinfo.c Renamed CURLDEBUG to CURL_MEMDEBUG
lib/Makefile.am Removed CURLDEBUG conditional compilation flag
include/curl/curl.h Marked CURL_VERSION_CURLDEBUG as deprecated in documentation
docs/tests/TEST-SUITE.md Updated documentation to reference DEBUGBUILD instead of CURLDEBUG
docs/libcurl/symbols-in-versions Added deprecation version 8.19.0 for CURL_VERSION_CURLDEBUG
docs/libcurl/curl_version_info.md Moved TrackMemory to deprecated section and updated description
docs/cmdline-opts/version.md Removed TrackMemory from feature documentation
docs/INSTALL-CMAKE.md Removed ENABLE_CURLDEBUG option documentation and updated libbacktrace documentation
configure.ac Removed CURLDEBUG configuration checks
appveyor.yml Updated test job names and removed separate CURLDEBUG toggles
appveyor.sh Removed CURLDEBUG CMake option
CMakeLists.txt Removed ENABLE_CURLDEBUG option and updated libbacktrace checks
CMake/CurlSymbolHiding.cmake Removed ENABLE_CURLDEBUG from condition
.github/workflows/windows.yml Removed ENABLE_CURLDEBUG and --disable-curldebug flags
.github/workflows/linux.yml Removed ENABLE_CURLDEBUG flag from TSAN job
Comments suppressed due to low confidence (1)

lib/version.c:461

  • The CURL_VERSION_CURLDEBUG flag is not being set when DEBUGBUILD is enabled. According to the PR description and the documentation update in docs/libcurl/curl_version_info.md (line 383-384), CURL_VERSION_CURLDEBUG should now 'Always the same as CURL_VERSION_DEBUG since 8.19.0'. The bitmask should include both flags for backward compatibility. Change the bitmask to: CURL_VERSION_DEBUG | CURL_VERSION_CURLDEBUG
  FEATURE("Debug",       NULL,                CURL_VERSION_DEBUG),

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vszakats vszakats changed the title build: merge CURLDEBUG option into DEBUGBUILD build: merge TrackMemory (CURLDEBUG) option into debug-enabled builds Jan 17, 2026
@vszakats vszakats changed the title build: merge TrackMemory (CURLDEBUG) option into debug-enabled builds build: merge TrackMemory (CURLDEBUG) into debug-enabled option Jan 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Continuous Integration cmdline tool feature-window A merge of this requires an open feature window libcurl API tests

Development

Successfully merging this pull request may close these issues.

3 participants