Skip to content

lib: fix two CURLDEBUG guards to be DEBUGBUILD#20328

Closed
vszakats wants to merge 1 commit intocurl:masterfrom
vszakats:debuguntangle
Closed

lib: fix two CURLDEBUG guards to be DEBUGBUILD#20328
vszakats wants to merge 1 commit intocurl:masterfrom
vszakats:debuguntangle

Conversation

@vszakats
Copy link
Member

@vszakats vszakats commented Jan 15, 2026

Both guard the use of CURL_DNS_SERVER debug env.

Follow-up to df2b4cc #18157
Follow-up to 02e9690 #17015
Follow-up to 59dc9f7 #13718

@github-actions github-actions bot added the name lookup DNS and related tech label Jan 15, 2026
@vszakats
Copy link
Member Author

vszakats commented Jan 15, 2026

I wonder if renaming CURLDEBUG to something else would help avoiding
regressions and improve readability? Its use spans accross many components,
and there is even a public symbol mentioning it, making a change somewhat
involved, but doable.

New name could be CURL_MEMDEBUG? (there is a related env with this
name used by tool_main and runtests, for CURLDEBUG builds.)

Would this be desired and useful?

@icing
Copy link
Contributor

icing commented Jan 15, 2026

I wonder if renaming CURLDEBUG to something else would help avoiding regressions and improve readability? Its use spans accross many components, and there is even a public symbol mentioning it, making a change somewhat involved, but doable.

New name could be CURL_MEMDEBUG? (there is a related env with this name used by tool_main and runtests, for CURLDEBUG builds.)

Would this be desired and useful?

CURLDEBUG is used for more than memdebug. I think the rename would be confusing.

@vszakats
Copy link
Member Author

vszakats commented Jan 15, 2026

I wonder if renaming CURLDEBUG to something else would help avoiding regressions and improve readability? Its use spans accross many components, and there is even a public symbol mentioning it, making a change somewhat involved, but doable.
New name could be CURL_MEMDEBUG? (there is a related env with this name used by tool_main and runtests, for CURLDEBUG builds.)
Would this be desired and useful?

CURLDEBUG is used for more than memdebug. I think the rename would be confusing.

True, strictly speaking. It also tracks open/close and
getaddrinfo/freeaddrinfo.

The feature is called "Track Memory" in public messages, also
missing the two extra tracked things. The primary (or initial)
focus was on memory.

IMO CURL_MEMDEBUG is an improvement over CURLDEBUG,
which is vague and caused mis-uses in the past, but I'm not
insisting on that particular name. (One advantage is that it has the
word DEBUG, along with DEBUGBUILD, helping greps.)

What would be a better name?

edit: CURL_RESDEBUG?

@vszakats vszakats closed this in 84ff0f6 Jan 15, 2026
@vszakats vszakats deleted the debuguntangle branch January 15, 2026 12:08
@bagder
Copy link
Member

bagder commented Jan 15, 2026

What's DEBUGBUILD even for?

@bagder
Copy link
Member

bagder commented Jan 15, 2026

I suspect that the source of the confusion is that we have two separate defines, and that all of us who ever debug curl have both set in debug builds.

@vszakats
Copy link
Member Author

vszakats commented Jan 15, 2026

DEBUGBUILD: makes a "debug-enabled" curl with all the hooks and special code to inject settings, values, etc, also for some runtests to run.
CURLDEBUG: Track Memory, which also includes tracking open/close and get/freeaddrinfo.

DEBUGBUILD by default implies CURLDEBUG, but they can be set separately.

Merging CURLDEBUG into DEBUGBUILD could fix with the confusion, and reduce build combinations, though it'd also mean that it's not possible run the full test suite with the production non-memdebug low-level functions. There is one such job in CI (on Linux), and can't off-the-bat decide if losing this is a real loss or not.

edit2: also the reverse, someone may want to trace memory in a production build? Can't say how useful that is. Probably not very common because it's been untangled relatively recently and was broken earlier. Perhaps another data point is that memdebug is now (since 2025 autumn) "cleanly" implemented and unlikely to cause a build issue in any configuration. Meaning enabling it has no longer this potential drawback.

edit: If merging, one way to go is remove build-level knobs, public facing separate "Track Memory" setting, and internally guard the few CURLDEBUG things with an internal macro bound to DEBUGBUILD (to allow grepping for these code parts). But for all intents and purposes, a debug-enabled build would unconditionally feature Track Memory.

@vszakats
Copy link
Member Author

patch proposal: #20331

vszakats added a commit that referenced this pull request Jan 19, 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)

Closes #20331
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build name lookup DNS and related tech tests

Development

Successfully merging this pull request may close these issues.

3 participants