Archived issue #0030430

Draw - command testgrid in parallel mode hangs if DRAW is launched without GUI

Open CASCADEOCCT:DRAWclosed6 public notes

Search issues

Description

It is impossible to run testgrid command in parallel mode using DRAW option -f (or -c): it just hangs.

The problem has been identified after fix of #0030377, however it does exist in all versions of OCCT that I have tried (6.8.0 till current), and for all tested versions of Tcl (including ActiveTcl 8.6, standard Tcl 8.6.4, 8.6.8, 8.7.0a - all built from sources).

The symptoms are as follows.

1. The test script succeeds in creating thread pool and setting up jobs, and hangs on waiting for jobs to complete. If job script is replaced by some Tcl command instead of exec (e.g. puts), it works fine. The jobs hangs only when it contains "exec" command, and does hang regardless of what executable is used (I have tried "git status" - just the same as executed successfully in the beginning of the testgrid command, and it hangs in the same way as DRAWEXE).

2. Under debugger, the execution successfully goes to creation of the process (in tclWinPipe.c, function TclpCreateProcess()): CreateProcess returns non-zero and yields some non-zero PID. The program then waits infinitely in

3. If non-existing command is fed to exec instead of DRAWEXE, the jobs complete correctly (all tests fail) but execution hangs in tpool::release again waiting for some events (threadPoolCmd.c, function TpoolRelease())

4. Testgrid works OK if Tk_Init() is called (it is called when DRAW is executed interactively but not with -c or -f options -- in that case it sets variable Draw_VirtualWindows to true an skips initialization of Tk). If DRAW is built without Tk at all, testgrid hangs in the same way.

In Tk_Init(), the crucial point looks to be the call to TkListCreateFrame(): if it is bypassed (in debugger), the hang up is reproduced.

5. Testgrid works OK if DRAW runs in batch mode, i.e. without creation of separate thread for evaluation of Tcl commands. That mode can be enabled by option -b, but requires patch for #0030377 to work.

Steps to reproduce

1. Create file "testgrid.tcl" containing single line "testgrid demo draw -overwrite"

2. Modify draw.bat adding arguments to DRAWEXE:

DRAWEXE -f path/to/testgrid.tcl

3. Launch draw.bat

Public activity

6 archived notes

Participants are labeled by their role within this record.

01Commenter 1
Attached script Attachment 1 (TCL) demonstrates the problem (the same or very similar) without any OCCT-specific commands, using pure Tcl code. It works fine in Tcl shell (tclsh.exe bug30340.tcl) or in DRAW if launched in interactive mode (with option -i), but hangs on releasing thread pools if DRAW is executed without TK (non-interactive mode, virtual windows).
02Commenter 2
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Thu Jan 10 08:17:04 2019 +0300

    0030430: Draw - command testgrid in parallel mode hangs if DRAW is launched without GUI
    
    Ensure that initialization of Tcl interpretor is performed in the same thread where commands are evaluated.
    
    Added test demo draw bug30430

Author: Author
Date: Sun Nov 18 19:53:10 2018 +0300

    0030377: DRAW, Windows - command executed via option -c fails on puts
    
    When DRAW on Windows is launched with option -c, the command is now properly transferred to Tcl thread (separate thread that runs Tcl interpretor on Windows except when DRAW is run in batch mode) for execution, instead of being evaluated in the main thread.
    
    Execution of DRAW in batch mode (option -b) is fixed by enabling proper initialization of the Tcl interpretor and replacement of backslashes in path to startup script by straight slashes on Windows in that mode.
    
    Declaration of global variables used for communication of console command between threads is moved to Draw_Window.hxx to ensure consistency.
    Function wscpy_s is used instead of memcpy to avoid possible buffer overrun.
03Commenter 3
Fix is pushed (together with fix for #0030377) to branch CR30430 and tested, see Jenkins job CR30430-master. Please review.
04Commenter 3
Please take the patch.
05Commenter 1
Combination -
OCCT branch : [archived branch] SHA - [revision removed]
Products branch : [archived branch] SHA - [revision removed]
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 16384.390000000094 / 16363.880000000001 [+0.13%]
Products
Total CPU difference: 7178.450000000044 / 7172.62000000003 [+0.08%]
Windows-64-VC14:
OCCT
Total CPU difference: 17734.359375 / 17727.875 [+0.04%]
Products
Total CPU difference: 8593.5625 / 8592.53125 [+0.01%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention
06Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]

Related records