Repository navigation
fix(libc): normalize valid mktime minus-one results - #4277
Merged
oneandonlydean merged 1 commit intoOct 12, 2026
Merged
oneandonlydean merged 1 commit into
oneandonlydean merged 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused implementation follows documented libc behavior and is covered by comprehensive cross-platform regression tests.
0 open findings
What changed in this PR
Fixes valid mktime results of -1 being mistaken for failures while preserving input on genuine failures.
Changes:
- Uses
tm_wdayto distinguish valid-1timestamps from errors. - Adds cross-platform normalization and failure regression tests.
- Registers the new test target.
| File | Description |
|---|---|
core/libs/tests/GuestMktime.cpp |
Tests both exports across timestamps, time zones, and failures. |
core/libs/prx/libc/src/Time.cpp |
Correctly handles valid mktime results of -1. |
core/libs/prx/libc/CMakeLists.txt |
Builds and registers the regression test. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This was referenced Oct 12, 2026
BharatYadav007
force-pushed
the
bharat/libc-mktime-negative-one
branch
from
October 12, 2026 04:55
bbd52a2 to
f0e852a
Compare
9 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A successful
mktimecan return-1for the second before the Unix epoch. The libc wrapper treated every-1result as a failure and left the guest calendar unnormalized.Initialize the host weekday to an invalid value and treat
-1as failure only if the host conversion leaves that value unchanged. This preserves the guest input on genuine failures and normalizes valid-1results through bothlibc_mktimeandmktime. The distinction follows the documentedtm_wdaycheck in Linux man-pages.Add a runtime test for both exports covering normalization around the epoch, multiple time zones, stale
EOVERFLOW, unrepresentable calendars, and the Windows CRT's existing pre-epoch failure behavior. Windows pre-epoch support remains as documented in TechnicalDebt.Replaces #3547, which was automatically closed under the open PR limit while #3542 was open. #3542 has now merged. The branch code is unchanged. Before the original submission, 132 open PR heads were checked for overlap; none implemented this change.
Tested
Validation performed on October 11 on branch commit
bbd52a249, based on upstreama11c8f7f7:Time.cppwith the regression fixture and ran it. The unmodified implementation failed at the valid-1timestamp; the fix passed. This was a focused native runtime check, not a full Linux build.guest_mktimepassed in 0.10 s andguest_time_conversionpassed in 0.13 s.libstarget passed.tools/check_conventions.py --base upstream/mainpassed.tools/check_test_registration.py buildpassed; all 638 test executables are registered.Checklist
.mdfiles or images added to the repository