Skip to content

fix(csp-batch): pass extents, not absent optional arrays, to batch_check_shapes - #145

Open
elijahmathews wants to merge 1 commit into
mainfrom
fix/ubsan-optional-extents
Open

elijahmathews wants to merge 1 commit into
mainfrom
fix/ubsan-optional-extents

Conversation

@elijahmathews

Copy link
Copy Markdown
Owner

What

The nightly ASan+UBSan job failed csp_batch and csp_batch_grad with csp_batch.f90:610:95: runtime error: signed integer overflow (run 44587837204).

Cause

batch_check_shapes (split out of the driver in #134) took the driver's optional arrays as optional dummies. With gfortran 13 at -O0, passing an absent optional assumed-shape array on makes the compiler read the bounds of its undefined descriptor to build a new one; UBSan reports the arithmetic as a signed overflow. The values are not used, so results were unaffected, but the sanitizer aborts. It showed only with CI's compiler (Ubuntu 24.04, gfortran 13.3) and an unoptimised build; Fedora's gfortran 16 at -O2 did not reproduce it.

Fix

The driver takes the extents under present() and passes an integer array ext; the checks are unchanged (same conditions, same statuses).

Verification

  • Ubuntu 24.04 container, gfortran 13.3, -Db_sanitize=address,undefined, default build type, -fno-sanitize-recover=all: test_csp_batch, test_csp_batch_grad, test_batch_equivalence exit 0, no runtime errors. Before the change, the same build aborted at csp_batch.f90:610:95.
  • Host FP64 and FP32: unit 45 OK, 0 failed, 1 skipped each; the three tests above exit 0.
  • Not run: R9700 device suite (the change touches no device code).

🤖 Generated with Claude Code

https://claude.ai/code/session_01MXDRCs7ATQiqhT6RLPLXR5

…eck_shapes

gfortran 13 at -O0 builds a new descriptor from an absent optional array that is passed on, reading its undefined bounds;
UBSan reports the arithmetic as a signed overflow (csp_batch.f90:610, nightly ASan+UBSan: csp_batch, csp_batch_grad).
The driver takes the extents under present() and passes integers. The checks are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MXDRCs7ATQiqhT6RLPLXR5
@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 67.44186% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.98%. Comparing base (d71a83b) to head (59be468).

Files with missing lines Patch % Lines
src/physics/opensps_csp_batch.f90 67.44% 0 Missing and 14 partials ⚠️

❌ Your patch check has failed because the patch coverage (67.44%) is below the target coverage (85.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #145      +/-   ##
==========================================
+ Coverage   74.93%   74.98%   +0.04%     
==========================================
  Files          51       51              
  Lines       14481    14497      +16     
  Branches     6089     6103      +14     
==========================================
+ Hits        10852    10871      +19     
  Misses       1482     1482              
+ Partials     2147     2144       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

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.

1 participant