Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2024-08-25
05:36
Merge [c83fa73b65ca3849]: Fix [abd489a1c]: TclStringCmp() calls functions through pointer to incor... check-in: c9ab508174 user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE
2023-12-30
00:20 • Closed ticket [abd489a1cf]: TclStringCmp() calls functions through pointer to in... artifact: db46df55c3 user: jan.nijtmans
2023-12-29
23:54
Fix [abd489a1c]: TclStringCmp() calls functions through pointer to incorrect type check-in: c83fa73b65 user: jan.nijtmans tags: trunk, main
2023-12-27
23:10
Fix [abd489a1c]: TclStringCmp() calls functions through pointer to incorrect type check-in: b88c726919 user: jan.nijtmans tags: core-8-6-branch
2023-10-13
14:09 • Pending ticket [abd489a1cf]: TclStringCmp() calls functions through pointer to i... artifact: 70a87b05c5 user: jan.nijtmans
13:27
Proposed fix for [abd489a1c]: TclStringCmp() calls functions through pointer to incorrect type. Modi... closed check-in: 6d9d5ac6a7 user: jan.nijtmans tags: bug-abd489a1c
07:24 • Add attachment abd489a1cf47.diff to ticket [abd489a1cf4782f0|abd489a1cf... artifact: c077eb7cc3 user: chrstphrchvz
07:22 • Add attachment abd489a1cf47.diff to ticket [abd489a1cf4782f0|abd489a1cf... artifact: 71b201fb6a user: chrstphrchvz
07:20 • New ticket [abd489a1cf] TclStringCmp() calls functions through pointer to incorr... artifact: ddd2f1ed33 user: chrstphrchvz

TclStringCmp() calls functions through pointer to incorrect type

Closed / Fixedabd489a1cf4782f0255f307c42370d3a5e27c464Created 3 years agoUpdated 3 years ago
Descriptionwiki2023-10-13 07:20:01
Example UBSan -fsanitize=function error:
% string compare a b
tcl/generic/tclCmdMZ.c:2863:10: runtime error: call to function TclpUtfNcmp2 through pointer to incorrect function type 'int (*)(const void *, const void *, unsigned long)'
tclUtf.c:1233: note: TclpUtfNcmp2 defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior tcl/generic/tclCmdMZ.c:2863:10 in 
-1

Some of the compare functions are public APIs, so I would suggest either using an enum to call functions directly, or wrapper functions (as done by the attached patch).

jan.nijtmanswiki2023-10-13 14:09:39

Thanks for the patch! Looks good.

In this case, it's slightly better to do the wrapping slightly different: [6d9d5ac6a75d7832].

jan.nijtmanswiki2023-12-30 00:20:14

This should be fixed in all branches now

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

Attachments: