Skip to content

Windows CI: a 1-row netCDF grid is read back with a collapsed y range (test/grdtrend/trend_xy_plot.sh) #9261

Open

Description

@Esteban82

I asked Claude to look for a solution to the failure of this test in the Windows CI, and this is its analysis. I am posting it to ask what you prefer to do about it.

test/grdtrend/trend_xy_plot.sh fails only in the Windows CI (MSVC 14.51.36231, Visual Studio 2026 image, Release /O2 /Ob2 /DNDEBUG, vcpkg netCDF 4.9.3): grdtrend prints Grid y increment <= 0.0 [data.grd] and crashes. I would like to ask what you prefer for this one, because I could not find the root cause.

What fails. The grid written by grdmath is valid and reads fine on Linux and through GDAL, but on the Windows CI the same call reads a 6x1 grid with y range 0/0:

gmt grdmath -R-1.2/1.2/-0.2/0.2 -I0.4 -r 0.5 X ADD X X MUL ADD X 3 POW ADD = row.grd
gmt grdinfo -C row.grd
  • good: row.grd -1.2 1.2 -0.2 0.2 -0.5 3.5 0.4 0.4 6 1 1 0
  • CI: row.grd -1.2 1.2 0 0 -0.5 3.5 0.4 0 6 0 1 0 (y range 0/0, y_inc 0, 0 rows)

It fails when the test runs alone (no -j4), and also outside the test (https://github.com/GenericMappingTools/gmt/actions/runs/38145255398). A 1-column x 6-row grid reads fine, GDAL reads y#actual_range={-0.2,0.2} fine, and the only netcdf.dll copies on PATH are vcpkg's. For a 1-row grid the y range comes only from actual_range (there is no usable y vector), in the y block of gmtnc_grd_info (src/gmt_nc.c, around lines 774-803); the x block has the same structure.

What I tried.

  • Any debug print inside gmtnc_grd_info, even a passive one, makes the failure disappear.
  • #pragma optimize("", off) around gmtnc_grd_info only, with nothing else changed, makes the test pass (https://github.com/GenericMappingTools/gmt/actions/runs/38176185877).
  • ASAN and UBSAN builds on Linux find nothing in this path, and I found no undefined behaviour by reading it.
  • A gmt 6.8.0_f6039ec build from September on a Windows 10 PC reads the grid correctly, but I don't know its toolset or flags. gmtnc_grd_info is identical to the one in master.

So it looks like an optimizer problem (compiler bug or an undefined behaviour that /O2 exploits), but I could not prove either.

Questions.

  1. Does anyone with a local MSVC 14.50 or 14.51 build reproduce the grdinfo output above?
  2. The 6.7.0 Windows binaries were linked with MSVC 14.50. Does the official 6.7.0 binary read the 1-row grid correctly? If not, users are affected and not only the test.
  3. How do you prefer to handle it: (a) the #pragma optimize change above, guarded by _MSC_VER (I have a 6-line patch ready), (b) mark the test with # GMT_KNOWN_FAILURE_WINDOWS, or (c) something else?

Reviewed with Claude Opus 5.5 (read-only review of the analysis). Written with Claude Sonnet 5.5.

Activity

  1. joa-quim commented on Oct 14, 2026

    @joa-quim
    Member

    The thing is, this test does not fail for me locally and also in the CI it started to fail only recently.

    C:\v>gmt grdmath -R-1.2/1.2/-0.2/0.2 -I0.4 -r 0.5 X ADD X X MUL ADD X 3 POW ADD = row.grd
    
    C:\v>grdinfo -C row.grd
    row.grd -1.2    1.2     -0.2    0.2     -0.5    3.5     0.4     0.4     6       1       1       0
    
  2. joa-quim commented on Oct 14, 2026

    @joa-quim
    Member

    Anyway, there is a true bug in here: the crash. What ever it ingests it should never crash.

  3. Esteban82 commented on Oct 14, 2026

    @Esteban82
    MemberAuthor

    3. . What ever it ingests it should never crash.

    I made #9266 for the crash.

  4. Esteban82 commented on Oct 15, 2026

    @Esteban82
    MemberAuthor

    2. The thing is, this test does not fail for me locally and also in the CI it started to fail only recently.

    That's what I thought. I think it would be best to use #GMT_KNOWN_FAILURE_WINDOWS.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions