Skip to content

genRoute aborts the whole process (OR-Tools CHECK failure) when there are no swaths to route #260

Open

Description

@00113844

When RoutePlannerBase::genRoute receives an F2CSwathsByCells without any swath, the coverage graph is empty. That happens, for example, when wide headland rings around obstacles leave no mainland. computeBestRoute then builds the depot as numNodes() - 1 = -1, and OR-Tools aborts the process:

F0000 ... routing_index_manager.cc:67] Check failed: start >= 0 (-1 vs. 0)
*** Check failure stack trace: ***

Because this is an abort() and not an exception, Python callers cannot catch it, and the interpreter dies with SIGABRT (shell exit code 134).

Reproduce (verified on v2.1.1, Python):

import fields2cover as f2c
ring = f2c.LinearRing(f2c.VectorPoint([f2c.Point(0,0), f2c.Point(10,0), f2c.Point(10,10), f2c.Point(0,10), f2c.Point(0,0)]))
cells = f2c.Cells(f2c.Cell(ring))
rp = f2c.RP_RoutePlannerBase()
rp.genRoute(cells, f2c.SwathsByCells(), False, 1e-4, True, 1, False)   # process aborts

Expected: a catchable exception, e.g. std::invalid_argument.

A related case: SolveWithParameters can return nullptr (no solution within the time limit), and the result is dereferenced without a check.

We hit this while benchmarking coverage strategies on paddocks with many in-field obstacles. A PR with a fix and a test follows.

Environment: Ubuntu 22.04, Fields2Cover v2.1.1 and develop (11e72c2) built from source, OR-Tools v9.9, GDAL 3.4, GEOS 3.10.2.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions