| Ticket UUID: | b362182e45704dd7bbd6aed91e48122035ea3d16 | |||
| Title: | Generation of virtual events through Tk_HandleEvent is unsafe | |||
| Type: | Bug | Version: | trunk | |
| Submitter: | fvogel | Created on: | 2016-04-21 21:58:09 | |
| Subsystem: | 99. Other | Assigned To: | fvogel | |
| Priority: | 8 | Severity: | Important | |
| Status: | Closed | Last Modified: | 2016-05-01 19:58:57 | |
| Resolution: | Fixed | Closed By: | fvogel | |
| Closed on: | 2016-05-01 19:58:57 | |||
| Description: |
Generation of virtual events through Tk_HandleEvent is unsafe because it may reenter the interpreter to call user-supplied scripts, and anything can then happen including destruction of the widget. However that is exactly what Tk does for: <<ListboxSelect>> <<Modified>> <<WidgetViewSync>> <<Selection>> For example, the call chain: TkTextTagCmd -> TkTextRedrawTag -> TextRedrawTag -> TkTextInvalidateLineMetrics -> TextInvalidateLineMetrics -> GenerateViewSyncEvent -> Tk_HandleEvent is *not* safe, because TkTextTagCmd() through TextInvalidateLineMetrics all continue to operate on the subject widget after Tk_HandleEvent() returns. Example script. Sourcing the following will crash: package require Tk pack [text .t] for {set i 1} {$i<10000} {incr i} { .t insert end "Hello world!\n" } bind .t <<WidgetViewSync>> {puts TRIGGERED! ; destroy .t} .t tag add mytag 1.5 8000.8 (Thanks to Joe English on TCLCORE for the hint about the possible problems with this). | |||
| User Comments: |
fvogel added on 2016-05-01 19:58:57:
Fix merged in core-8-6-branch and trunk. fvogel added on 2016-04-22 20:18:18: Non-regression test case added: [cd123af9]. This test crashes before the fix [1795939c] and does no longer crash with this fix. fvogel added on 2016-04-21 22:05:55: Fix proposed here: [1795939c] The fix consists in calling TkSendVirtualEvent() instead of Tk_HandleEvent(). | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki