Skip to content

fix(libc): check daylight availability at the representable year edges - #19901

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
Ketz7:fix/libc-mktime-daylight-hint-year-edges
Nov 14, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
Ketz7:fix/libc-mktime-daylight-hint-year-edges

Conversation

@Ketz7

@Ketz7 Ketz7 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

What

  • guest_mktime fails on Ubuntu 22.04 (glibc 2.35) with daylight hint at a representable year edge failed.
  • Within a year of the tm_year limits, mktime skipped the daylight availability query because its one-year search window leaves the representable calendar, and passed tm_isdst > 0 to the host mktime.
  • glibc 2.35 returns -1 with EOVERFLOW for tm_isdst = 1 in any zone without daylight saving, for ordinary years too (2024 in UTC0, IST-5:30, and December of the edge years in EST5EDT); newer glibc ignores the hint, so the result depended on the host C library.
  • At those edges the query now runs 400 years inward, where the Gregorian calendar repeats and the zone applies the same rule (its earliest offset before the first transition, its recurring rule after the last), so an unavailable hint is dropped as it is for every other year. Years whose search window is representable are unchanged.
  • The libc technical debt entry for mktime daylight hints records where the boundary query is made.

Tested

  • Ubuntu 22.04 under WSL2, GCC 11.4, glibc 2.35, full build with BUILD_TESTING=ON.
  • Host check: glibc 2.35 mktime with tm_isdst = 1 returns -1 (errno 75) in IST-5:30 and UTC0 at year 124 and at both tm_year limits.
  • guest_mktime fails on main and passes with the change.
  • ctest -R '^guest_(mktime|time|freebsd_clocks)': 13/13 pass, including guest_time_conversion, guest_time_extras and guest_freebsd_clocks, which passed on main too.
  • Windows and macOS not run locally; their paths share this query.
  • tools/pr_overlap.py --branch could not compare 28 open PRs that conflict with main in docs/dev/debt/libc.md (feat(libc): add the std::__sce_v2 thread start, timed wait, clock and processor count calls #9447 and fix(libc): write a 36-byte struct tm as the console does #10409 also in Time.cpp); compared by hand against their merge bases, none edits libc_mktime_nid_postfix or the mktime daylight hints debt entry.
  • tools/check_conventions.py --base origin/main and git diff --check pass.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@JJenkx

JJenkx commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 6b8f973b1d, merged onto main 74900e8b0f (d1beb9ae0d, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.

  • application_heap_default, application_heap_exit_order, application_heap_invalid_metadata, application_heap_lazy, application_heap_replacement, application_heap_scripting, application_heap_stats, application_heap_stats_default, application_heap_stats_missing, application_heap_without_parameters, exception_personality, file_position, file_stream_status, file_streams, guest_access, guest_allocating_strings, guest_allocator_failures, guest_array_callbacks, guest_atoi, guest_atomic_builtins, guest_backtrace, guest_bad_any_cast_node_access, guest_bad_optional_access, guest_bessel, guest_binary_word, guest_bounded_search_guards, guest_bounds_checking, guest_bsearch_packed, guest_bzero_extent, guest_call_trace, guest_call_trace_abort, guest_case_compare_random, guest_char_search_boundary, guest_character, guest_cnd_at_thread_exit, guest_collate, guest_cxa_guard, guest_daemon, guest_decimal_boundary, guest_demangle, guest_device_name, guest_dinkumware_atomics, guest_dinkumware_division, guest_dinkumware_float_bits, guest_dinkumware_internals, guest_directory, guest_dsign, guest_dynamic_cast, guest_environment, guest_errors, guest_execute_once, guest_filesystem_error, guest_fiopen, guest_float_builtins, guest_floating_point, guest_fopen_errors, guest_fopen_long_host_path, guest_formatting, guest_freopen_host_log, guest_freopen_host_standard, guest_future_category, guest_fwide, guest_generic_category, guest_gets, guest_heap_report_for_game, guest_heap_rounding_overflow, guest_heap_trace_info, guest_hostname, guest_index, guest_integer_builtins, guest_interfaces, guest_libc_cnd_init_default_name, guest_libc_cnd_timed_wait, guest_libc_mutex_init_with_name, guest_libc_shared_mutex, guest_libc_static_imports, guest_libc_threads, guest_lifecycle, guest_locale, guest_malloc_lifecycle, guest_math, guest_math_elementary, guest_math_exact, guest_memccpy_bounds, guest_memcmp_protected, guest_memcpy_protected, guest_memmem_boundary, guest_memmove_snapshot, guest_memory_resource, guest_memrchr, guest_memset_extent, guest_mktime, guest_multibyte_locale, guest_new_handler, guest_new_handler_default_heap, guest_overflow_error, guest_owned_memory, guest_owned_memory_limits, guest_path_case, guest_path_drive_component, guest_qsort, guest_queue, guest_radix64, guest_raise_except, guest_random_device_seed, guest_random_state, guest_reallocalign, guest_realpath, guest_rune_locale, guest_safe_errors, guest_scan_count, guest_sce_v2_at_thread_exit, guest_sce_v2_binary_scaling, guest_sce_v2_exceptions, guest_sce_v2_exp, guest_sce_v2_facet_ids, guest_sce_v2_filesystem, guest_sce_v2_filesystem_calls, guest_sce_v2_float_constants, guest_sce_v2_float_helpers, guest_sce_v2_iomanip, guest_sce_v2_locale, guest_sce_v2_locale_basics, guest_sce_v2_locimp_references, guest_sce_v2_log_gamma, guest_sce_v2_multiprecision, guest_sce_v2_pmsw, guest_sce_v2_stream_init, guest_sce_v2_string_to_integer, guest_sce_v2_timespec64, guest_sce_v2_xtime_diff_to_millis, guest_search, guest_set_env, guest_sigvec, guest_span_protected, guest_standard_streams, guest_standard_streams_closed_stdout, guest_standard_streams_exclusive_stdout, guest_standard_streams_reopen_closed_stdout, guest_standard_streams_update_stdout, guest_std_atomic_wait, guest_std_atomic_wait_kernel, guest_std_execute_once, guest_std_thread_hardware_concurrency, guest_stdio_variadic, guest_stpcpy_extent, guest_strcat_extent, guest_strcmp_boundary, guest_strcoll_boundary, guest_strcpy_extent, guest_stream_buffer_host_write, guest_stream_purge, guest_strftime, guest_string_compare, guest_strings, guest_strlcat_boundary, guest_strncat_protected, guest_strncmp_boundary, guest_strncpy_protected, guest_strndup_guarded, guest_strnstr_boundary, guest_strpbrk_boundary, guest_strtod_subnormal, guest_strxfrm_boundary, guest_substring_protected, guest_syslog, guest_syslog_reload, guest_thrd_start, guest_thread_callback_abi, guest_throw_bad_array_new_length, guest_time_conversion, guest_time_extras, guest_time_return, guest_timespec_get, guest_timingsafe_boundary, guest_tokenizer_protected, guest_underflow_error, guest_unwind_accessors, guest_update_env, guest_vector_algorithms, guest_wcscmp_boundary, guest_wcslen_boundary, guest_wcsncat_extent, guest_wcsncmp_boundary, guest_wcsncpy_extent, guest_wcsrtombs, guest_wcsrtombs_s, guest_wide_char_boundary, guest_wide_compare_blocks, guest_wide_conversion, guest_wide_copy_extent, guest_wide_formatting, guest_wide_length_protected, guest_wide_scan_blocks, guest_wide_set_boundary, guest_wide_span_boundary, guest_wide_stream_scan, guest_wide_strings, guest_wide_substring_boundary, guest_wide_token_boundary, guest_wmemchr_boundary, guest_wmemcmp_boundary, guest_wmemcpy_extent, guest_wmemmove_snapshot, guest_wmemset_extent, guest_working_directory, log_file, log_macros, log_macros_timestamps, mspace, precise_wait, run_report, run_report_revision, thread_name, unwind_cursor, unwind_enclosing_function, windows_backtrace_failure_report, windows_backtrace_failure_report_once, windows_backtrace_report, windows_crash_stack_words, windows_crash_without_stack_words, windows_exceptions, windows_guest_main_stack, windows_guest_main_stack_entry, windows_guest_main_stack_failure, windows_mappings_release pass in 3 of 3 runs, none skipped.

AI-assisted: yes.

@github-actions

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 7447 docs/dev/debt/libc.md
PR 7715 docs/dev/debt/libc.md
PR 8150 docs/dev/debt/libc.md
PR 8965 docs/dev/debt/libc.md
PR 9087 docs/dev/debt/libc.md
PR 9340 docs/dev/debt/libc.md
PR 9447 core/libs/prx/libc/src/Time.cpp
docs/dev/debt/libc.md
PR 9466 docs/dev/debt/libc.md
PR 9526 docs/dev/debt/libc.md
PR 10409 core/libs/prx/libc/src/Time.cpp
docs/dev/debt/libc.md
PR 11172 docs/dev/debt/libc.md
PR 11332 docs/dev/debt/libc.md
PR 11661 docs/dev/debt/libc.md
PR 11689 docs/dev/debt/libc.md
PR 11698 docs/dev/debt/libc.md
PR 12184 docs/dev/debt/libc.md
PR 12682 docs/dev/debt/libc.md
PR 12688 docs/dev/debt/libc.md
PR 12700 docs/dev/debt/libc.md
PR 12849 docs/dev/debt/libc.md
PR 12965 docs/dev/debt/libc.md
PR 15973 docs/dev/debt/libc.md
PR 16791 docs/dev/debt/libc.md
PR 17557 docs/dev/debt/libc.md
PR 17558 docs/dev/debt/libc.md
PR 18380 docs/dev/debt/libc.md
PR 18405 docs/dev/debt/libc.md

@oneandonlydean
oneandonlydean merged commit 167edb1 into boykopovar:main Nov 14, 2026
22 checks passed
@Ketz7
Ketz7 deleted the fix/libc-mktime-daylight-hint-year-edges branch November 16, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants