On 12/29/19 1:47 PM, Andreas Otto wrote:
> Hi, I just receive a CORE Dump in tcl "thread" code
>
> Thread code:
>>>>>>>>>>>>>>>>>>>>>>>>>
> foreach _F $argv {
> thread::create "
> [setupVar LLabel _F PROJECT_SRC PROJECT_BUILD PWD YEAR WRITE FORCE VERBOSE VVERBOSE FIX PRINT]
>
> source $wrk
> "
> }
> <<<<<<<<<<<<<<<<<<<<<<<<<
>
> the code start for every file in "argv" a thread job to update the file data.
> all the "work" code is in the a worker file at "wrk". The "environment is set by variables "LLabel _F PROJECT_SRC..." using the "setupVar" proc in the script "..." argument of "thread::create".
>
>
I have used threads a lot lately and I have found that it core dumps way
more frequently than normal Tcl. However, I have also found that that
was all due to the programmer's error.
That said, from looking at your code and reading your description, it is
likely that your thread initialization script is not doing what you may
think it is doing. You are sending it the *result* of [setUpVar]
invoked in the main thread. Try this syntax:
foreach _F $argv {
set tid [thread::create {thread::wait}]
thread::send $tid {setUpVar LLabel _F PROJECT_SRC PROJECT_BUILD PWD
YEAR WRITE FORCE VERBOSE VVERBOSE FIX PRINT}
thread::send $tid $wrk
# and may be start things off if $wrk is not doing it already
thread::send $tid start_working
}