Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
slydiman opened this issue May 17, 2024 · 2 comments · Fixed by #92701

Comments

@slydiman
Copy link
Contributor

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.

@llvmbot
Copy link
Collaborator

llvmbot commented May 17, 2024

@llvm/issue-subscribers-lldb

Author: Dmitry Vasilyev (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(&amp;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.
</details>

slydiman added a commit to slydiman/llvm-project that referenced this issue May 17, 2024
…python crash

The python crashed with the exit code 0xC0000409 (STATUS_STACK_BUFFER_OVERRUN) on the command `frame variable ss_neg_seconds` running on Windows x86_64. See this issue for details llvm#92574
@Michael137
Copy link
Member

Michael137 commented May 17, 2024

FYI @mordante

slydiman added a commit to slydiman/llvm-project that referenced this issue May 19, 2024
slydiman added a commit that referenced this issue May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants