Ticket Hash: | 0e55608dbd661663d7efeb4dc91c1c815ab5ba6e | |||
Title: | Crash in Itcl when using Iwidgets in multiple threads | |||
Status: | Closed | Type: | Code_Defect | |
Severity: | Critical | Priority: | Immediate | |
Subsystem: | Resolution: | External_Bug | ||
Last Modified: | 2024-08-24 10:11:38 | |||
Version Found In: | 4.2.4 | |||
User Comments: | ||||
petrokaz added on 2024-08-23 14:17:07:
Minimal example:
This code runs 8 threads in parallel each showing an iwidget (pushbutton or anything else, doesn't matter) and after 1-2 minutes it crashes with:
Windows 10, Tcl 8.6.14 (from Magicsplat), Itcl 4.2.4, Itk 4.2.6, Iwidgets 4.1. The same crash happens when using the Itk written in pure Tcl That's why I'm convinced the problem is in Itcl rather than Itk, and the stack trace points to Itcl as well. Probably, there is a mutex missing somewhere. I didn't try to reproduce it on Linux. Maybe related bug sebres added on 2024-08-23 16:40:00: > That's why I'm convinced the problem is in Itcl rather than Itk, Then please provide a reproducible example using Itcl only (without widgets, tk and whatever)... However I guess it is not Itk, but rather tk. > and the stack trace points to Itcl as well. Well, it maybe just an after effect, but... > Probably, there is a mutex missing somewhere. I never heard that tk is really thread-safe (vice versa, I always thought it is not)... You can surely use it in multi-threaded application, but have to guarantee that only one thread (mostly main thread) is communicating with tk and serves its events in the event cycle. Sorry, but I'll close it as incorrect or external bug. chw added on 2024-08-23 18:26:09: The pointer petrokaz gave to the itcl ticket https://core.tcl-lang.org/itcl/tktview/4fff3fc277 is most likely the root of the evil. See that ticket for my proposed fix, which I've tested with petrokaz' example code snippet on Wine and observed no crashes. Regarding multi-threaded Tk: Windows should be fine, Linux/X11/Mac not so much. sebres added on 2024-08-24 10:11:38: Although I don't think that even on Windows tk is thread-safe, [4fff3fc277] is indeed an issue... And your PoC looks good, so I'll cherry-pick it now. Thx, Christian. |