Crash in Itcl when using Iwidgets in multiple threads

Liste des GroupesRevenir à cl tcl 
Sujet : Crash in Itcl when using Iwidgets in multiple threads
De : vivid.tree7955 (at) *nospam* fastmail.com (Petro Kazmirchuk)
Groupes : comp.lang.tcl
Date : 23. Aug 2024, 13:29:53
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <va9vc0$thcj$1@dont-email.me>
User-Agent : Mozilla Thunderbird
Minimal example:
package require Thread
set thread_script {
     package require Iwidgets
     iwidgets::pushbutton .btn -text [thread::id]
     pack .btn
     after 4000 [list thread::release [thread::id]]
     thread::wait
}
for {set i 0} {$i<1000} {incr i} {
     thread::create -preserved $thread_script
     after 500
}
This code runs 8 threads in parallel each showing an iwidget (pushbutton or anything else, doesn't matter) and after ~1 minute it crashes with:
Unhandled exception at 0x00007FF8846DA6E4 (itcl424t.dll) in tclsh86t.exe: 0xC0000005: Access violation reading location 0x0000000000000018.
Windows, Tcl 8.6.14, Itcl 4.2.4, Itk 4.2.6, Iwidgets 4.1.
The same crash happens when using the Itk written in pure Tcl: https://chiselapp.com/user/rene/repository/itk/home
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.
I understand that both Iwidgets and Itcl are legacy that is barely maintained, that's why I'm not raising a bug in Fossil that very few people would notice. What I'm asking instead from a much wider audience here is for a workaround. Is it possible to change my code somehow to avoid the crash? Of course, preserving the basic multi-threaded architecture.
The original code is a huge framework that can't be rewritten to separate GUI into one main thread.
Thanks in advance,
Petro

Date Sujet#  Auteur
23 Aug 24 * Crash in Itcl when using Iwidgets in multiple threads6Petro Kazmirchuk
23 Aug 24 +* Re: Crash in Itcl when using Iwidgets in multiple threads2Harald Oehlmann
23 Aug 24 i`- Re: Crash in Itcl when using Iwidgets in multiple threads1Petro Kazmirchuk
23 Aug 24 +- Re: Crash in Itcl when using Iwidgets in multiple threads1Schelte
25 Aug 24 +- Re: Crash in Itcl when using Iwidgets in multiple threads1undroidwish
25 Aug 24 `- Re: Crash in Itcl when using Iwidgets in multiple threads1undroidwish

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal