Skip to content

Guard map path sampling against invalid dlon/dlat to prevent macOS pscoast crashes#9071

Draft
Copilot wants to merge 3 commits into
masterfrom
copilot/fix-github-actions-job-macos
Draft

Guard map path sampling against invalid dlon/dlat to prevent macOS pscoast crashes#9071
Copilot wants to merge 3 commits into
masterfrom
copilot/fix-github-actions-job-macos

Conversation

Copilot AI commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

The macOS CI failure came from pscoast_JE2 crashing in gmtlib_lonpath after an invalid path-sampling step produced a pathological allocation size. This change hardens map path generation when projection edge cases yield non-finite or non-positive dlon/dlat.

  • Root cause

    • gmtlib_lonpath / gmtlib_latpath computed allocation sizes from GMT->current.map.dlat / GMT->current.map.dlon without guarding invalid values.
    • In azimuthal singularity scenarios, this could cascade into impossible allocation requests and segfault.
  • Code changes

    • Added defensive checks in:
      • src/gmt_map.c::gmtlib_lonpath
      • src/gmt_map.c::gmtlib_latpath
    • When dlat/dlon is non-finite or <= 0, both functions now return a safe 2-point fallback path instead of entering adaptive sampling/allocation logic.
  • Behavioral impact

    • Normal projections/path sampling are unchanged.
    • Degenerate projection-step cases no longer attempt invalid huge allocations; they degrade safely to a minimal path.
if (!isfinite (GMT->current.map.dlat) || GMT->current.map.dlat <= 0.0) {
    gmt_M_malloc2 (GMT, tlon, tlat, 2U, NULL, double);
    tlon[0] = tlon[1] = lon;
    tlat[0] = lat1;
    tlat[1] = lat2;
    *x = tlon;
    *y = tlat;
    return (2ULL);
}

Copilot AI changed the title [WIP] Fix failing GitHub Actions job macOS Guard map path sampling against invalid dlon/dlat to prevent macOS pscoast crashes Jun 24, 2026
Copilot AI requested a review from ES-Solar June 24, 2026 18:25

@joa-quim joa-quim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't have yet a AI policy but I think PRs submitted by agents are not acceptable. Every PR should be submitted by an human.

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.

3 participants