Skip to content

fix: sequence from_chars pointer advances in to_time_point#17

Merged
ruoka merged 3 commits into
masterfrom
cursor/critical-bug-management-f627
Jul 21, 2026
Merged

fix: sequence from_chars pointer advances in to_time_point#17
ruoka merged 3 commits into
masterfrom
cursor/critical-bug-management-f627

Conversation

@cursor

@cursor cursor Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

xson::to_time_point used std::from_chars(++p, p+N, ...), which unsequences a write and read of p (undefined behavior). On common right-to-left evaluation (e.g. g++), that silently parsed the wrong digit spans so every valid ISO-8601 string could decode to the wrong time_point.

Trigger

xson::to_time_point("1970-01-01T00:00:00.000Z") should be epoch (0 ms); on g++ it returned a far-from-epoch value. Same for pre-epoch and modern dates.

Fix

Advance p between from_chars calls; return timestamp_type; add round-trip and known-value regression tests.

Test plan

  • ./tools/CB.sh debug test --tags='\[xson\]' — 415/415 passed
  • Standalone g++ repro of old vs new parse behavior
Open in Web View Automation 

cursoragent and others added 3 commits July 20, 2026 22:56
from_chars(++p, p+N, ...) unsequenced the increment with the end-pointer
read, which is undefined behavior and silently parsed the wrong digits on
common compilers (e.g. month from one character). Advance p between calls
so ISO-8601 round-trips stay exact.

Co-authored-by: Kaius  Ruokonen <ruoka@users.noreply.github.com>
Default ostream precision (6 significant digits) silently corrupted
JSON number_type values on stringify/parse (e.g. 123456789.123… became
123457000). Emit max_digits10 via to_chars and reject non-finite values.

Co-authored-by: Kaius  Ruokonen <ruoka@users.noreply.github.com>
Lengths other than YYYY-MM-DD / YYYY-MM-DDTHH:MM:SS.sssZ used to parse
the date only and silently drop a present time (e.g. …T12:00:00Z →
midnight). Failed from_chars left zero fields and built unspecified
dates. Require exact forms, separators, full-width digits, and valid
ranges.

Co-authored-by: Kaius  Ruokonen <ruoka@users.noreply.github.com>
@ruoka
ruoka marked this pull request as ready for review July 21, 2026 00:06
@ruoka
ruoka merged commit c4354b0 into master Jul 21, 2026
4 checks passed
@ruoka
ruoka deleted the cursor/critical-bug-management-f627 branch July 21, 2026 00:06
ruoka added a commit that referenced this pull request Jul 21, 2026
* fix: sequence from_chars pointer advances in to_time_point

from_chars(++p, p+N, ...) unsequenced the increment with the end-pointer
read, which is undefined behavior and silently parsed the wrong digits on
common compilers (e.g. month from one character). Advance p between calls
so ISO-8601 round-trips stay exact.

Co-authored-by: Kaius  Ruokonen <ruoka@users.noreply.github.com>

* fix: stringify doubles with max_digits10 precision

Default ostream precision (6 significant digits) silently corrupted
JSON number_type values on stringify/parse (e.g. 123456789.123… became
123457000). Emit max_digits10 via to_chars and reject non-finite values.

Co-authored-by: Kaius  Ruokonen <ruoka@users.noreply.github.com>

* fix: reject truncated/corrupt ISO-8601 in to_time_point

Lengths other than YYYY-MM-DD / YYYY-MM-DDTHH:MM:SS.sssZ used to parse
the date only and silently drop a present time (e.g. …T12:00:00Z →
midnight). Failed from_chars left zero fields and built unspecified
dates. Require exact forms, separators, full-width digits, and valid
ranges.

Co-authored-by: Kaius  Ruokonen <ruoka@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Kaius  Ruokonen <ruoka@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants