Tk Source Code

View Ticket
Login
2026-10-13
19:54 • Closed ticket [05411ee5]: Revised text: inserting text with an -elide 0 tag into an elided range fails an assertion plus 4 other changes artifact: 45f32572 user: nab
19:54
Merge elide0-insert-in-elided-range and elide-walk-skipped-lines (Serhiy Storchaka): fix [05411ee533] and [ad458a3a72] (tests btree-14.121 and 14.120). The tests of [bbaa3c1e5f] btree-14.120 and 14.121 become btree-14.125 and 14.126. check-in: 07716463 user: nab tags: revised_text, tip-466
17:45 • Ticket [05411ee5] Revised text: inserting text with an -elide 0 tag into an elided range fails an assertion status still Open with 3 other changes artifact: 3594b9d2 user: serhiy.storchaka
17:23 • Ticket [05411ee5]: 3 changes artifact: ecfffc48 user: nab
17:21 • New ticket [67335ebb] Revised text: changing the -elide option of a tag to or from {} fails an assertion. artifact: e020d03d user: nab
2026-10-11
13:58 • Closed ticket [5b97764f]: Revised text: tag raise/lower does not update the elide state plus 6 other changes artifact: 7f6ad12b user: nab
12:42 • Ticket [05411ee5] Revised text: inserting text with an -elide 0 tag into an elided range fails an assertion status still Open with 3 other changes artifact: b1fe54b2 user: nab
12:42 • New ticket [5b97764f] Revised text: tag raise/lower does not update the elide state. artifact: f4543c1a user: nab
2026-10-10
12:14 • Ticket [05411ee5] Revised text: inserting text with an -elide 0 tag into an elided range fails an assertion status still Open with 3 other changes artifact: a0523a3c user: serhiy.storchaka
12:13
Fix [05411ee533]: inserting text with an -elide 0 tag into an elided range failed an assertion. Such text is not elided: split the enclosing elided range as for untagged text. Test btree-14.121. closed check-in: a7fad206 user: serhiy.storchaka tags: elide0-insert-in-elided-range
11:39 • New ticket [05411ee5] Revised text: inserting text with an -elide 0 tag into an elided range fails an assertion. artifact: c1a932b1 user: serhiy.storchaka

Ticket UUID: 05411ee5331ba3325dcf0f971ca80c82eb979e86
Title: Revised [text]: inserting text with an -elide 0 tag into an elided range fails an assertion
Type: Bug Version: revised_text
Submitter: serhiy.storchaka Created on: 2026-10-10 11:39:25
Subsystem: 18. [text] Assigned To:
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2026-10-13 19:54:57
Resolution: Fixed Closed By:
    Closed on:
Description:

In the revised text widget, inserting text with a tag that has -elide 0 into a range elided by another tag fails an assertion (build with --enable-symbols):

pack [text .t]
.t tag configure A -elide 0
.t tag configure B -elide 1
for {set i 1} {$i <= 25} {incr i} {.t insert end "row $i abcdef\n"}
.t tag add B 7.6 9.3
.t insert 8.4 "xy\n" A
tkTextBTree.c: TkBTreeFindStartOfElidedRange: Assertion `SegmentIsElided(sharedTextPtr, segPtr, textPtr)' failed.
Untagged text, or text with a tag without -elide, is inserted without errors. The legacy text widget in main is not affected. Found by fuzzing the elide handling while looking at [ad458a3a72].

User Comments: nab added on 2026-10-13 19:54:57:

Merged into revised_text with [07716463c0|07716463c0], as you asked. Thank you.


serhiy.storchaka added on 2026-10-13 17:45:58:

Please go ahead and merge both into revised_text. Thank you for testing them.


nab added on 2026-10-13 17:23:13:

Hi Serhiy,

Both of your branches for the revised text widget are still open: elide0-insert-in-elided-range [a7fad20697] (this ticket) and elide-walk-skipped-lines [8d0c690381] ([ad458a3a72]). They merge together without conflict into the current revised_text [eea332730c], and text*.test passes with both (2108 tests, no failure, debug build).

Our fuzzing of revised_text keeps hitting the assertion of this ticket, which hides other failures. Will you merge them into revised_text, or are you fine with us doing it?

Separately, the -elide {} case mentioned above is fixed: [67335ebb70], merged into revised_text with [eea332730c].


nab added on 2026-10-11 12:42:19:

The fix looks right to me: when the highest-priority elide tag of the new text has -elide 0, the text is not elided, so it has to split the enclosing range like untagged text, and a7fad20697 sends it through that path.

Tested on a debug build (--enable-symbols):

  • The script of this ticket fails the assertion on revised_text 43fddb67e7 and passes on the branch.
  • text*.test on the branch: 2086 tests, no failure.
  • A fuzzer that inserts text with tag lists, which none of the existing ones does: a tag with -elide 0, two tags with -elide 1 and a plain tag, mixed with tag add/remove, delete, replace, tag configure -elide 0|1|{} and undo/redo. The oracle is the consistency checks of .t debug 1 plus get -displaychars, compared with the elide state computed from tag names and the tag priorities (the oracle passes on the legacy widget). Over 300 seeds, with single-line and multi-line ranges, without tag raise/lower and without soft hyphens, the seeds that fail this assertion go from 68 and 127 to 3 and 7 with the branch, and no seed that passed before fails with it.

The 10 remaining seeds all fail on tag configure ... -elide {}, not on an insertion. Minimal case, same assertion (SegmentIsElided in TkBTreeFindStartOfElidedRange):

text .t
.t tag configure B -elide 1
.t tag configure C -elide 1
.t insert end zxk
.t tag add C 1.0 1.1
.t tag add B 1.1 1.3
.t tag configure B -elide {}

It also fails with 8d0c690381 and with both branches merged; -elide 0 instead of {} passes.

The fuzzer found three other bugs, reported in f39133da29 (with a fix), 5b97764fc6 and cef1ef9d52. I can attach the fuzzer if it is useful.


serhiy.storchaka added on 2026-10-10 12:14:46:

Such text is not elided, so the enclosing elided range has to be split, as for untagged text inserted at the meeting point of two elide tags; but the update for the -elide 0 tag searched the start of the elided range from the new text. Proposed fix in branch elide0-insert-in-elided-range, [a7fad20697], test btree-14.121. Related fixed cases: [bdd1f64523] (switching -elide) and [859cb411ce] (adding a -elide 0 tag).