Skip to content

Stabilize Coverity Scan triage and document known false positives - #266

Merged
antonwolfy merged 3 commits into
mainfrom
coverity-triage-docs
Sep 3, 2026
Merged

Stabilize Coverity Scan triage and document known false positives#266
antonwolfy merged 3 commits into
mainfrom
coverity-triage-docs

Conversation

@antonwolfy

Copy link
Copy Markdown
Collaborator

Summary

Coverity Scan runs weekly against mkl_umath. Every finding to date is a false positive in generated code — the Cython-generated _patch_numpy.c and the generate_umath.py-generated __umath_generated.c — not in the code we maintain. A Cython version bump regenerates _patch_numpy.c wholesale, churning the Coverity CIDs and silently dropping all prior triage on the boilerplate.

This PR makes triage durable and records the policy so the noise stays filtered while real signal keeps getting reviewed. It ports the approach from IntelPython/mkl_random#164, adapted to mkl_umath's translation units.

Changes

  • Pin Cython in the Coverity workflow only (cython==3.3.0 in .github/workflows/coverity.yml). A Cython bump regenerates _patch_numpy.c, which churns CIDs and their triage; pinning keeps the generated code stable between scans. The pin takes effect because the build runs with --no-build-isolation. Production builds leave Cython unpinned in pyproject.toml, so shipped wheels and Python-version support are unaffected.
  • Add coverity/README.md, a triage guide with:
    • Where findings come from across the four translation units — hand-written ufuncsmodule.c, template-generated mkl_umath_loops.c, generate_umath.py-generated __umath_generated.c, and Cython _patch_numpy.c.
    • A Cython pin rationale and an opt-in Coverity Project Component to group (not hide) the generated units.
    • A review checklist that keeps mkl_umath/src/ and __pyx_pf_* bodies in scope rather than blanket-excluding the generated units.
    • The five verified Minor-severity false positives matched on checker + mechanism: one DEADCODE in InitOperators (__umath_generated.c) plus four Cython __pyx_*/__Pyx_* findings (DEADCODE tp_traverse, DEADCODE with-statement codegen, DEADCODE import helper, FORWARD_NULL in __cinit__).
    • Evaluated and declined options (modeling files, hard-excluding the generated units via cov-manage-emit).

Rationale

We deliberately do not hard-exclude the generated units: that would also drop the __pyx_pf_* bodies (the C translation of our .pyx logic) and could hide a genuine bug. The chosen approach cuts the recurring noise (CID stability via the pin + a documented triage policy) while preserving coverage of the hand-written and template-generated C, where a real defect is most likely to appear.

Changelog

Added a Changed entry under [dev].

Pin Cython in the Coverity Scan workflow (only) so the generated
_patch_numpy.c is byte-stable between scans. Coverity derives CIDs from a
hash of the analyzed code, so an unpinned Cython bump regenerates the
file, resets every CID, and silently discards prior triage on the
Cython-boilerplate false positives. Production builds keep Cython
unpinned in pyproject.toml, so this does not affect shipped wheels or
Python support.

Add coverity/README.md recording where findings come from across the four
translation units (hand-written ufuncsmodule.c, template-generated
mkl_umath_loops.c, generate_umath.py-generated __umath_generated.c, and
Cython _patch_numpy.c), the five verified Minor-severity false positives
(one DEADCODE in InitOperators plus four Cython __pyx_*/__Pyx_* findings),
and a review checklist that keeps first-party sources and __pyx_pf_*
bodies in scope rather than blanket-excluding the generated units.
@antonwolfy antonwolfy self-assigned this Sep 3, 2026
@antonwolfy antonwolfy added this to the 0.6.0 release milestone Sep 3, 2026
@antonwolfy
antonwolfy marked this pull request as ready for review September 3, 2026 10:02
antonwolfy added a commit to IntelPython/mkl_fft that referenced this pull request Sep 3, 2026
Backport of IntelPython/mkl_umath#266, adapted to mkl_fft.

- Pin cython==3.3.0 in the Coverity workflow (only there, not in
  pyproject.toml) so the generated _pydfti.c stays byte-stable between
  scans and Coverity CIDs plus their triage survive. Works because the
  scan build uses --no-build-isolation.
- Add coverity/README.md: where findings come from across mkl_fft's two
  translation units (template-generated mklfft.c, which is our DFTI
  logic and stays in scope, and Cython-generated _pydfti.c), the
  Cython-pin rationale, an opt-in Project Component, a review checklist,
  and the one verified Cython-boilerplate false positive that applies to
  mkl_fft (a DEADCODE in the tp_traverse slot of Cython genexpr scope
  structs).

mkl_umath's other documented false positives (the __umath_generated.c
InitOperators DEADCODE, the with-statement and __Pyx__Import DEADCODE,
and the _patch_impl FORWARD_NULL) do not occur in mkl_fft and are
deliberately omitted.
antonwolfy added a commit to IntelPython/mkl_fft that referenced this pull request Sep 3, 2026
Backport of IntelPython/mkl_umath#266, adapted to mkl_fft.

- Pin cython==3.3.0 in the Coverity workflow (only there, not in
  pyproject.toml) so the generated _pydfti.c stays byte-stable between
  scans and Coverity CIDs plus their triage survive. Works because the
  scan build uses --no-build-isolation.
- Add coverity/README.md: where findings come from across mkl_fft's two
  translation units (template-generated mklfft.c, which is our DFTI
  logic and stays in scope, and Cython-generated _pydfti.c), the
  Cython-pin rationale, an opt-in Project Component, a review checklist,
  and the verified false-positive families for the mkl_fft project.

The known false positives are grouped by checker + mechanism from the
current scan: Cython-generated boilerplate (tp_traverse DEADCODE,
version/ABI-guarded helper DEADCODE, a reference-cleanup UNUSED_VALUE, a
CHECKED_RETURN) and two dead-by-construction families in our own .pyx
(redundant is-NULL guards Cython already proves, and an intentional
in-place placeholder stub) - all triaged Intentional / Ignore. The
genuine __create_descriptor_1d UNUSED_VALUE defects were fixed in
#365, not suppressed, so mklfft.c stays in scope.

mkl_umath's own documented false positives were not ported blind; the
table was rebuilt from mkl_fft's own scan and generated code.
antonwolfy added a commit to IntelPython/mkl_fft that referenced this pull request Sep 3, 2026
Backport of IntelPython/mkl_umath#266, adapted to mkl_fft.

- Pin cython==3.3.0 in the Coverity workflow (only there, not in
  pyproject.toml) so the generated _pydfti.c stays byte-stable between
  scans and Coverity CIDs plus their triage survive. Works because the
  scan build uses --no-build-isolation.
- Add coverity/README.md: where findings come from across mkl_fft's two
  translation units (template-generated mklfft.c, which is our DFTI
  logic and stays in scope, and Cython-generated _pydfti.c), the
  Cython-pin rationale, an opt-in Project Component, a review checklist,
  and the verified false-positive families for the mkl_fft project.

The known false positives are grouped by checker + mechanism (matched on
checker + mechanism, not CID, since CIDs reset on a Cython bump):
Cython-generated boilerplate (tp_traverse DEADCODE, version/ABI-guarded
helper DEADCODE, a reference-cleanup UNUSED_VALUE, a CHECKED_RETURN) and
two dead-by-construction families in our own .pyx (redundant is-NULL
guards Cython already proves, and an intentional in-place placeholder
stub) - all triaged Intentional / Ignore.

mkl_umath's own documented false positives were not ported blind; the
table was rebuilt from mkl_fft's own scan and generated code.
@antonwolfy
antonwolfy merged commit 0258b10 into main Sep 3, 2026
64 of 75 checks passed
@antonwolfy
antonwolfy deleted the coverity-triage-docs branch September 3, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants