Sponsored Content
Skip to content

fix: Resolve MSVC Debug build failure in JobQueue.h; re-enable _CRTDBG_MAP_ALLOC in CI - #6993

Merged
bthomee merged 7 commits into
developfrom
pratik/fix-msvc-crtdbg-boost-context-build-issue-on-windows
Apr 24, 2026
Merged

fix: Resolve MSVC Debug build failure in JobQueue.h; re-enable _CRTDBG_MAP_ALLOC in CI#6993
bthomee merged 7 commits into
developfrom
pratik/fix-msvc-crtdbg-boost-context-build-issue-on-windows

Conversation

@pratikmankawde

@pratikmankawde pratikmankawde commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

High Level Overview of Change

MSVC Debug builds fail to compile JobQueue.cpp due to a preprocessor collision between the CRT debug allocator macros and Boost.Context's pool-backed stack allocator. This PR:

  1. Fixes the root cause by narrowing the boost/coroutine2 include in include/xrpl/core/JobQueue.h to only the sub-headers the project actually uses, avoiding the broken boost/context/pooled_fixedsize_stack.hpp entirely.
  2. Reverts the CI workaround from PR ci: Fix build errors on windows #6562, which disabled _CRTDBG_MAP_ALLOC in CI to paper over this same collision. With the root cause fixed, the gate is no longer needed.

Context of Change

Reported build failure (local MSVC Debug build):

boost/context/pooled_fixedsize_stack.hpp(89,34): error C2760: syntax error: ',' was unexpected here; expected ')'
  while compiling class template 'boost::context::basic_pooled_fixedsize_stack'
  (compiling source file 'src/libxrpl/core/detail/JobQueue.cpp')

Root cause:

  • cmake/XrplCompiler.cmake defines _CRTDBG_MAP_ALLOC for Debug MSVC builds.
  • _CRTDBG_MAP_ALLOC makes <crtdbg.h> redefine malloc / free as function-like preprocessor macros that expand to _malloc_dbg / _free_dbg.
  • boost/context/pooled_fixedsize_stack.hpp (Boost 1.90) calls .malloc() / .free() as member functions on boost::pool, without the BOOST_PREVENT_MACRO_SUBSTITUTION guard or defensive (p.malloc)() parenthesization that protects other Boost pool headers.
  • The preprocessor expands these member calls textually into a syntax error.

PR #6562 previously disabled _CRTDBG_MAP_ALLOC in CI as a symptomatic workaround (reasoning: CI doesn't consume Debug artifacts). That left the bug reproducible on any developer doing a local Windows Debug build — which is exactly the failure mode reported here.

Why this fix:

  • The project never references pooled_fixedsize_stack — only coroutine, pull_type, push_type, asymmetric_coroutine, and protected_fixedsize_stack. The umbrella boost/coroutine2/all.hpp was dragging in three unused stack allocators, one of which is broken under _CRTDBG_MAP_ALLOC.
  • Switching to the narrower boost/coroutine2/coroutine.hpp + boost/coroutine2/protected_fixedsize_stack.hpp avoids the broken header entirely. No preprocessor fences or _MSC_VER gymnastics needed.
  • The broken boost/context/pooled_fixedsize_stack.hpp has only four transitive entry points in Boost (coroutine2/all.hpp, coroutine2/pooled_fixedsize_stack.hpp, fiber/all.hpp, fiber/pooled_fixedsize_stack.hpp) — none of which the project now uses.
  • Once the root cause is fixed, the CI gate from PR ci: Fix build errors on windows #6562 is redundant. Removing it restores parity between CI and local Debug builds.
  • Side benefit: slightly faster header-parse time across 34 translation units that transitively include JobQueue.h.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Test Plan

  • clang Linux builds unaffected (symbols still resolve via the narrower headers)
  • Pre-commit hooks pass
  • Levelization check clean
  • Windows MSVC Release CI build passes (exercised by the PR's windows-amd64-release matrix leg)
  • Windows MSVC Debug build⚠️ not exercised by PR CI. Per .github/scripts/strategy-matrix/generate.py, Windows Debug only runs in the scheduled all matrix (on merges to develop/release), not in PR minimal mode. This PR should be validated locally on Windows Debug before merge, or expect Debug coverage to land only post-merge via the nightly matrix.

Future Tasks

Consider adding a Windows Debug leg to the PR matrix for faster validation of this class of bug — or at minimum, document in CONTRIBUTING.md that Windows Debug regressions will only surface on nightly runs.

`boost/coroutine2/all.hpp` transitively pulls in
`boost/context/pooled_fixedsize_stack.hpp`, which calls `.malloc()` and
`.free()` as member functions on `boost::pool`. With `_CRTDBG_MAP_ALLOC`
defined in non-CI Debug MSVC builds (cmake/XrplCompiler.cmake), the CRT
redefines `malloc` / `free` as macros that expand textually, mangling the
member calls into a syntax error.

`pooled_fixedsize_stack` is unused in the project. Replace the umbrella
include with `coroutine2/coroutine.hpp` (provides `coroutine`, `pull_type`,
`push_type`, `asymmetric_coroutine`) and `coroutine2/protected_fixedsize_stack.hpp`,
sidestepping the broken header entirely.

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues.

Review by Claude Opus 4.6 · Prompt: V15

@pratikmankawde

Copy link
Copy Markdown
Contributor Author

@ximinez Try building this branch locally on Windows, and let me know if it works fine.

PR #6562 disabled `_CRTDBG_MAP_ALLOC` in CI to work around a macro
collision in `boost/context/pooled_fixedsize_stack.hpp`. The previous
commit resolves that collision at the source by narrowing the
Boost.Coroutine2 include so the broken header is no longer pulled in.

With the root cause fixed, restore the original define scope. CI now
exercises the same Debug preprocessor configuration as local MSVC
builds, guarding against regressions of the same bug.
@pratikmankawde pratikmankawde changed the title fix: Narrow Boost.Coroutine2 include in JobQueue.h for MSVC Debug builds fix: Resolve MSVC Debug build failure in JobQueue.h; re-enable _CRTDBG_MAP_ALLOC in CI Apr 22, 2026

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues.

Review by Claude Opus 4.6 · Prompt: V15

@codecov

codecov Bot commented Apr 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.9%. Comparing base (7a449ed) to head (47702ab).
⚠️ Report is 6 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #6993     +/-   ##
=========================================
- Coverage     81.9%   81.9%   -0.0%     
=========================================
  Files         1010    1010             
  Lines        76383   76383             
  Branches      7530    7529      -1     
=========================================
- Hits         62522   62521      -1     
- Misses       13861   13862      +1     
Files with missing lines Coverage Δ
include/xrpl/core/JobQueue.h 100.0% <ø> (ø)

... and 2 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ximinez ximinez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wonderful! I'm testing a few different configurations, but the first ones I've tried have worked perfectly.

Comment thread include/xrpl/core/JobQueue.h Outdated
pratikmankawde and others added 2 commits April 23, 2026 12:00
Co-authored-by: Ed Hennis <ed@ripple.com>

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues.

Review by Claude Opus 4.6 · Prompt: V15

@ximinez

ximinez commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Let's get this merged ASAP. Thanks!

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues.

Review by Claude Opus 4.6 · Prompt: V15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses an MSVC Debug build failure caused by _CRTDBG_MAP_ALLOC interacting badly with a transitive Boost header, by narrowing Boost.Coroutine2 includes in JobQueue.h to avoid pulling in the problematic boost/context/pooled_fixedsize_stack.hpp. With the root cause mitigated, it also restores _CRTDBG_MAP_ALLOC for CI Debug builds to keep CI behavior aligned with local Windows Debug builds.

Changes:

  • Replace boost/coroutine2/all.hpp with narrower Boost.Coroutine2 headers in include/xrpl/core/JobQueue.h.
  • Re-enable _CRTDBG_MAP_ALLOC for MSVC Debug builds in CI by removing the is_ci exclusion in cmake/XrplCompiler.cmake.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
include/xrpl/core/JobQueue.h Narrows Boost includes to avoid transitively including pooled_fixedsize_stack under _CRTDBG_MAP_ALLOC.
cmake/XrplCompiler.cmake Restores _CRTDBG_MAP_ALLOC definition for all MSVC Debug builds (including CI) to remove the prior workaround.

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

Comment thread include/xrpl/core/JobQueue.h Outdated
#include <boost/context/protected_fixedsize_stack.hpp>
#include <boost/coroutine2/all.hpp>
#include <boost/coroutine2/coroutine.hpp>
#include <boost/coroutine2/protected_fixedsize_stack.hpp>

Copilot AI Apr 23, 2026

Copy link

Choose a reason for hiding this comment

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

boost/coroutine2/protected_fixedsize_stack.hpp appears unused here (the actual stack allocator used by JobQueue::Coro is boost::context::protected_fixedsize_stack in include/xrpl/core/Coro.ipp). Keeping this extra include undermines the stated goal of narrowing transitive Boost headers; consider removing it (or switching the implementation to use the coroutine2 wrapper) so the header set matches what’s actually referenced.

Suggested change
#include <boost/coroutine2/protected_fixedsize_stack.hpp>

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@pratikmankawde I suppose this header is necessary or clang-tidy would also have flagged it, wouldn't you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this could be one of those false negatives, because boost/coroutine2/protected_fixedsize_stack.hpp contains
using protected_fixedsize_stack = boost::context::protected_fixedsize_stack;. Just the aliasing. So keeping the include doesn't really change much, so does removing. I'll remove it anyway, since I am not using the aliased type later.

Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
…dows' of github.com:XRPLF/rippled into pratik/fix-msvc-crtdbg-boost-context-build-issue-on-windows

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues.

Review by Claude Opus 4.6 · Prompt: V15

@pratikmankawde pratikmankawde added the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label Apr 24, 2026
@bthomee
bthomee added this pull request to the merge queue Apr 24, 2026
Merged via the queue into develop with commit 158df53 Apr 24, 2026
3 checks passed
@bthomee
bthomee deleted the pratik/fix-msvc-crtdbg-boost-context-build-issue-on-windows branch April 24, 2026 17:05
marek-foss-neti pushed a commit to marek-foss-neti/rippled that referenced this pull request May 5, 2026
…G_MAP_ALLOC in CI (XRPLF#6993)

Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
Co-authored-by: Ed Hennis <ed@ripple.com>
beartec-jpg pushed a commit to beartec-jpg/FalconLedger that referenced this pull request Jun 1, 2026
…G_MAP_ALLOC in CI (XRPLF#6993)

Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
Co-authored-by: Ed Hennis <ed@ripple.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants