Skip to content

[lldb][Windows] LibcxxChronoTimePointSecondsSummaryProvider() failed on Windows x86_64 because of incorrect limits #92574

@slydiman

Description

@slydiman

lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp, Line 1101:

  // The date time in the chrono library is valid in the range
  // [-32767-01-01T00:00:00Z, 32767-12-31T23:59:59Z]. A 64-bit time_t has a
  // larger range, the function strftime is not able to format the entire range
  // of time_t. The exact point has not been investigated; it's limited to
  // chrono's range.
  const std::time_t chrono_timestamp_min =
      -1'096'193'779'200; // -32767-01-01T00:00:00Z
  const std::time_t chrono_timestamp_max =
      971'890'963'199; // 32767-12-31T23:59:59Z

  const std::time_t seconds = ptr_sp->GetValueAsSigned(0);
  if (seconds < chrono_timestamp_min || seconds > chrono_timestamp_max)
    stream.Printf("timestamp=%" PRId64 " s", static_cast<int64_t>(seconds));
  else {
    std::array<char, 128> str;
    std::size_t size =
        std::strftime(str.data(), str.size(), fmt, gmtime(&seconds));
    if (size == 0)
      return false;

gmtime(&seconds) provided by Windows SDK 10.0.22621.0 has the following limits
Min: -43'200 // 1969-12-31T12:00:00
Max: 32'536'850'399 // 3001-01-19T21:59:59

gmtime() triggers an assert and the python crashed with the exit code 0xC0000409 (STATUS_STACK_BUFFER_OVERRUN) on the test TestDataFormatterLibcxxChrono.py on Windows x86_64 because of this issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions