← Back to Pull requests

fix(daal): declare the placement deletes that match DAAL_NEW_DELETE's placement new #4000

Open
unknown opened this pull request with 513 lines diff across 6 files
View on GitHub
unknown unknown commented on Nov 06, 2026 14:14 UTC
Author

Description

DAAL_NEW_DELETE() (cpp/daal/include/services/daal_defines.h) declares a class-level placement operator new(std::size_t, void ) (and new[]) but no matching placement operator delete(void , void ). MSVC reports C4291 ("no matching operator delete found; memory will not be freed if initialization throws an exception") for every placement new of such a class.

That is what the scikit-learn-intelex Windows build in the conda-forge feedstock shows: Cython 3.1+ constructs the SharedPtr members of daal4py's cdef classes with __Pyx_default_placement_construct, i.e. new (static_cast<void >(x)) T();, so there is one warning per wrapped SharedPtr<...> type (example: conda-forge/scikit-learn-intelex-feedstock#85, Windows job). Cython 3.0 emitted the same placement new inline in tp_new; 3.1 only moved it into a helper, which is why the warnings now come with template-instantiation notes.

Is it a real leak? No. The placement form constructs into storage the caller already owns (for daal4py, the Python object), so there is nothing to free if the constructor throws, and SharedPtr's default constructor only sets three pointers to null and cannot throw. The macro has been like this since the first open-source commit.

Change. Two no-op placement deletes are added to the macro. They are called only if a constructor throws inside placement new. Ordinary new/delete and new[]/delete[] are unchanged and still go through daal_calloc/daal_free; (void , void ) is not a usual deallocation function, so it never competes with the existing sized operator delete(void , std::size_t).

API/ABI. Additive only. The macro is used in 10 public headers, including class DAAL_EXPORT Base. On Linux the new inline members are not emitted unless used. On Windows, MSVC exports the inline members of a dllexport class, so onedal_core.dll gains two Base symbols; no existing symbol, layout or vtable changes, and binaries built against older headers keep working.

Tests. New suite //cpp/daal/src/services/test:tests (registered in //cpp/daal:tests next to the threading suite), new_delete_unit.cpp:

  • static_asserts that SharedPtr<int> and a Base subclass have operator delete(void , void ) and operator delete[](void , void ). Without the change the file does not compile (invalid static_cast from void ()(void *, std::size_t)).

  • a throwing constructor in placement new into caller-owned storage, placement new of a SharedPtr, and plain new/delete/new[]/delete[] of a Base subclass.
  • bazel test --config=host //cpp/daal/src/services/test:tests //cpp/daal/src/threading/test:tests passes. GCC and Clang have no counterpart to C4291, so the warning itself can only be checked on the Windows CI (MSVC); the scikit-learn-intelex side needs this header in a released oneDAL to see the warnings go away.

    ---

    <details>
    <summary>Checklist:</summary>

    Completeness and readability

  • I have commented my code, particularly in hard-to-understand areas.

  • I have updated the documentation to reflect the changes or created a separate PR with updates and provided its number in the description, if necessary. Not applicable: no documented behaviour changes.

  • Git commit message contains an appropriate signed-off-by string _(see CONTRIBUTING.md for details)_.

  • I have resolved any merge conflicts that might occur with the base branch.
  • Testing

  • I have run it locally and tested the changes extensively.

  • All CI jobs are green or I have provided justification why they aren't.

  • I have extended testing suite if new functionality was introduced in this PR.
  • Performance

  • I have provided justification why performance and/or quality metrics have changed or why changes are not expected. Not expected: the new functions are only reachable when a constructor throws during placement new.
  • </details>

    🤖 Generated with Claude Code

    Diff: 513 lines (+384 / -129) across 6 files Reviewer: Alexandr-Solovev Review duration: 6458m
    All Vouch review confidence checks passed
    Residual risk 0.25 = Change Risk (0.48) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 513 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.373
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #4000"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.7% (MEDIUM) · Higher = larger blast radius
    47.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.4% · Safe to merge
    25.4%