Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-01-18
02:00 • Closed ticket [96e5c814eb]: Signed integer overflow in Clock_str2wideInt() p... artifact: 1c67613203 user: sebres
01:56
merge 9.0 (fix for [96e5c814eb9ed955]) check-in: ead6ad70c1 user: sebres tags: trunk, main
01:47
closes [96e5c814eb9ed955]: fixes sanitizer RTM-error signed integer overflow (no-trapv pragma also r... check-in: 508a2af36a user: sebres tags: core-9-0-branch
01:43
closes [96e5c814eb9ed955]: fixes sanitizer RTM-error signed integer overflow (no-trapv pragma also r... check-in: f954da0082 user: sebres tags: core-8-branch
2026-01-06
06:09 • Ticket [96e5c814eb] Signed integer overflow in Clock_str2wideInt() status st... artifact: 5a0a3fdafa user: apnadkarni
03:56 • Ticket [96e5c814eb]: 3 changes artifact: c15be4499a user: cdubois
2025-12-29
20:39 • Ticket [96e5c814eb]: 3 changes artifact: ddd78a2f06 user: sebres
00:18 • Ticket [1819da1b50] UBsan errors in clock status still Open with 3 other cha... artifact: 01a5a9482d user: chrstphrchvz
2025-09-20
18:27 • New ticket [96e5c814eb] Signed integer overflow in Clock_str2wideInt(). artifact: 07cb8ca210 user: chrstphrchvz

Signed integer overflow in Clock_str2wideInt()

Closed / Fixed96e5c814eb9ed95591ce30904943025c35673a96Created 1 year agoUpdated 319 days ago
Descriptionmarkdown2025-09-20 18:27:44

UBSan -fsanitize=signed-integer-overflow errors as encountered during these tests:

  • clock-6.9: generic/tclClockFmt.c:192:21: runtime error: signed integer overflow: -9223372036854775800 - 9 cannot be represented in type 'Tcl_WideInt' (aka 'long long')

  • clock-6.10: generic/tclClockFmt.c:182:21: runtime error: signed integer overflow: 9223372036854775800 + 8 cannot be represented in type 'Tcl_WideInt' (aka 'long long')

  • clock-6.10a: generic/tclClockFmt.c:182:16: runtime error: signed integer overflow: 2767011611056432742 * 10 cannot be represented in type 'Tcl_WideInt' (aka 'long long')

  • clock-6.10a-: generic/tclClockFmt.c:192:16: runtime error: signed integer overflow: -2767011611056432742 * 10 cannot be represented in type 'Tcl_WideInt' (aka 'long long')

But maybe this is won't-fix, given the usage of # pragma GCC optimize("no-trapv").

sebreswiki2025-12-29 20:39:15

This is not directly won't-fix, but the overflow is indeed covered below by check whether original is smaller/larger (depending on sign) than result after operation. We can surely rewrite it more strict to pass the sanitizer.

cduboisplain2026-01-06 03:56:16
I’d like to help make this UBSan-clean. Based on sebres’ note, it seems the current logic is fine but UBSan is flagging intermediate signed overflow.

Do you have a preferred direction for addressing this — e.g., restructuring the arithmetic to avoid overflow in signed space (pre-checks / bounds checks), or another approach you consider idiomatic here?

If you’re OK with it, I can draft a patch and validate it with UBSan, focusing on the reported tests (clock-6.9/6.10/6.10a).
apnadkarniplain2026-01-06 06:09:42
I too would prefer these to be fixed even if benign just to avoid clutter and missing real warnings.
sebreswiki2026-01-18 02:00:11

Shall be fixed in all branches (based on new clock-engine), starting from [f954da0082db5ac1], thus close now.

Log in (anonymous is fine) to add a comment.