Skip to content

stat.cc crashes: stats.cc:201 Check failed: seconds >= 0.0 (-0.784035 vs. 0) #4907

@alex-klimov

Description

@alex-klimov

What version of OR-Tools and what language are you using?
Version: main/v9.14
Language: C++/Go

Which solver are you using
CP-SAT

What operating system (Linux, Windows, ...) and version?
Ubuntu 24

What did you do?
Hard to reproduce, timing issue.

  1. Solver configured with 4 workers, fails on rather large run, which takes up to a minute to finish. Sometimes solver crashes with:
    WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
    F0000 00:00:1762346483.864814 391862 stats.cc:201] Check failed: seconds >= 0.0 (-0.784035 vs. 0)
    *** Check failure stack trace: ***
    @ 0x155dc08 (unknown)
    @ 0x155dc84 (unknown)
    @ 0x155d70c (unknown)
    @ 0x6763ec (unknown)
    @ 0x10c69d0 (unknown)
    @ 0xd2e91c (unknown)
    @ 0xd2d02c (unknown)
    @ 0xd2e56c (unknown)
    @ 0xd2e32c (unknown)
    @ 0xd2de88 (unknown)
    @ 0x6ad270 (unknown)
    @ 0x1154ea8 (unknown)
    @ 0x1157738 (unknown)
    @ 0x11576bc (unknown)
    @ 0x1157620 (unknown)
    @ 0x11575d8 (unknown)
    @ 0x11575b8 (unknown)
    @ 0xf70426581ae0 (unknown)
    @ 0xf7042624595c (unknown)
  1. Ubuntu adjusts the clock with ntpdate - likely this is important.

What did you expect to see
No crashes on timing issues.

Anything else we should know about your project / environment

Likely fix would be at ortools/sat/subsolver.h to check for duration to be positive:

  // Note that this is protected by the global execution mutex and so it is
  // called sequentially. Subclasses do not need to call this.
  void AddTaskDuration(double duration_in_seconds) {
    ++num_finished_tasks_;
    wall_time_ += duration_in_seconds;
    if (duration_in_seconds > 0) {
      timing_.AddTimeInSec(duration_in_seconds);
    }
  }

This follows the same pattern already used in that file for AddTaskDeterministicDuration

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions