Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2024-08-26
14:25
Merge [692ac81a3a01d582]: Merge 8.6 (string tests, also illustrating bug [edb4b065f49b9e51])Merge [6... check-in: d9ea81d7c0 user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE
14:21
Merge [5d52c6d7302b320e]: Fix [edb4b065f4] - crash on string compare. check-in: 551f710347 user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE
2024-04-04
14:45 • Ticket [edb4b065f4] Crash in string compare of empty string against byte array</... artifact: afb44fb856 user: jan.nijtmans
14:29 • Ticket [edb4b065f4]: 5 changes artifact: b595583a93 user: sebres
12:28 • Closed ticket [edb4b065f4]. artifact: dcbcc5694f user: jan.nijtmans
12:28 • Ticket [edb4b065f4]: 3 changes artifact: 7c63586194 user: jan.nijtmans
12:20 • Ticket [edb4b065f4]: 3 changes artifact: 241e24c107 user: sebres
12:11 • Pending ticket [edb4b065f4]. artifact: 78a63a42e5 user: sebres
2024-03-28
22:12 • Ticket [edb4b065f4]: 5 changes artifact: 718cb197a4 user: sebres
21:27 • Ticket [edb4b065f4]: 5 changes artifact: e8e48ba889 user: jan.nijtmans
2024-03-27
20:46 • Closed ticket [edb4b065f4]. artifact: d4d92d7bf3 user: sebres
20:18
fixes SF [edb4b065f49b9e51]: cherry-picked from 5d52c6d7302b320e] check-in: ac30912bcc user: sebres tags: core-8-branch
20:13
merge 8.6 (string tests, also illustrating bug [edb4b065f49b9e51]) check-in: 633a20378a user: sebres tags: core-8-branch
17:59 • Ticket [edb4b065f4] Crash in string compare of empty string against byte array</... artifact: 70980ec1c8 user: sebres
17:51 • Ticket [edb4b065f4]: 3 changes artifact: 814c4075fb user: apnadkarni
17:49 • Ticket [edb4b065f4]: 3 changes artifact: 9aaea12ebc user: apnadkarni
17:42 • Ticket [edb4b065f4]: 3 changes artifact: c36ae1c17e user: apnadkarni
17:41
Fix [edb4b065f4] - crash on string compare check-in: 5d52c6d730 user: apnadkarni tags: trunk, main
17:24 • Ticket [edb4b065f4] Crash in string compare of empty string against byte array</... artifact: 3033c215b8 user: sebres
16:17 • Ticket [edb4b065f4]: 3 changes artifact: 9b15c9bd6b user: apnadkarni
16:16 • Ticket [edb4b065f4]: 3 changes artifact: ef7d1c9945 user: apnadkarni
16:14
Proposed fix for [edb4b065f4] closed check-in: f5f42a6211 user: apnadkarni tags: bug-edb4b065f4
15:46
Tests for [edb4b065f49] crash. check-in: 5497a1412b user: apnadkarni tags: bug-edb4b065f4
15:37 • New ticket [edb4b065f4] Crash in string compare of empty string against byte arr... artifact: 82f4325e0c user: apnadkarni

Crash in string compare of empty string against byte array

Closed / Fixededb4b065f49b9e51304ccdba4ee4e126ba379b0dCreated 3 years agoUpdated 3 years ago
Descriptionmarkdown2024-03-27 15:37:36

The following crashes Tcl

% string compare -length 1 "" [binary decode hex 00]
...boom...

Investigating...

Referenced by3
apnadkarniplain2024-03-27 16:16:48
Crash occurs if either -length and -nocase is specified but not otherwise.
apnadkarniplain2024-03-27 16:17:33
Proposed fix in [f5f42a6211].
sebreswiki2024-03-27 17:24:56

The affected versions are basically >= 8.7.
And test-cases can be added (cherry-picked) for 8.6 too.

apnadkarnimarkdown2024-03-27 17:42:54

Fixed in [5d52c6d730].

apnadkarniplain2024-03-27 17:49:56
@sebres,

I realized that but given limited time and resources, I do not plan on spending any effort

- working on 8.6 except for actual bugs that are present there

- working on 8.7 unless there is a concrete plan or need to officially release it

Given serious lack of programmers working on Tcl, every bit of work, even the half hour it might take merging / running tests on two platforms before commits, etc. is time better spent on 9.0 or extensions in my view. That's the path I'm taking.

Others may differ.
apnadkarniplain2024-03-27 17:51:58
Fixed for 9.0 but leaving open since bug has been marked for 8.7 if anyone wants to pursue that.
sebres Ticket [edb4b065f4]: 3 changes [History diff]2024-03-27 17:59:45
sebresmarkdown2024-03-27 20:46:20

Fixed for all branches, 8.6 has now the same tests (excepting few compat tweaks).

Thus close.

jan.nijtmanswiki2024-03-28 21:27:46

Thanks, @sebres, for backporting. It's highly appreciated!

However, I don't think it's a good idea burdening all other test-cases, determining the encoding, just for a single "string.test" that needs it. Therefore, I reverted this part, sorry! Asciifying the testcase makes it portable for any Tcl version, that's how it should be done IMHO.

Anyway, thanks!

sebreswiki2024-03-28 22:12:27

Huh?... The cost of tcltest::fileEncoding will be approximately 50µs per file. What by the 200 files amounts to "burdening" 10 milliseconds.

As for the "asciifying" in [03cf62003a88a5f2] - it is not quite kosher.

Firstly, ab\u7266 is not the same as ab牦 (first is unicode string, another is object with utf-8 bytes), what may change the test, internally. Still worse it may look by replacement for ü - \xFC, which is single-byte, and may work for windows with cp1252 as system encoding (and unix with utf-8 by fallback from ascii through cp1252), but may fail for platforms with another single-byte system encodings, not to mention the backport to Tcls where it behaves similar to 8.5 (where \xFC may be bytearray).

Then maybe better something like [encoding convertfrom cp1252 \xFC].

However, if one see the costs... is the effort, difference to 8.7/9.0 (and a removal of, imho, nice feature) justified?

sebresplain2024-04-04 12:11:40
@Jan, ping?
sebres Ticket [edb4b065f4]: 3 changes [History diff]2024-04-04 12:20:08
jan.nijtmanswiki2024-04-04 12:28:23

Hi Sergey.

I'm holding my objection. In Tcl 8.7 and 9.0, all test-cases are already ran in utf-8 mode, so the benefit of your change is 0.0000%

The only benefit would be in Tcl 8.6, and it only involves 7 test-cases. That way too little to impose this burden on 8.7 and 9.0 IMHO. Those 7 test-cases involve "string equal" which is fed with utf-8 strings anyway: the Ascification (as is done everywhere else in Tcl 8.6 tests) doesn't change the heart of the testcase.

Sorry!

jan.nijtmans Closed ticket [edb4b065f4]. [History diff]2024-04-04 12:28:35
sebresmarkdown2024-04-04 14:29:58

the Ascification (as is done everywhere else in Tcl 8.6 tests) doesn't change the heart of the testcase.

But it does. If you don't want to consider UTF vs. UNICODE difference (why? the tests may cover different pieces in code and code of 8.6 is different to 8.7/9.0), it should be revisited at least for windows platform with non-cp1252 system encodings, just to illustrate:

% encoding convertfrom cp1252 \xFC
ü
% encoding convertfrom cp1251 \xFC
ь
jan.nijtmanswiki2024-04-04 14:45:25

I think you are totally mistaken. Writing "\xFC" in a script is not decoded using the system-encoding, it's always the +U00FC Unicode code-point. On the other hand, using ü in a script will give a different result depending on the system-encoding. That's why using utf-8 always prevents many unexpected problems.

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