Crash in TKDraw::~Draw_Interpretor::Tcl_Exit

Hello,

i have converted my project to OCC 6.7.1. It has worked well with OCC 6.5.5
Now i have a crash if my program is closed.
Here is the Call Stack:
> TKDraw.dll!Tcl_ExternalToUtfDString(Tcl_Encoding_ * encoding, const char * src, int srcLen, Tcl_DString * dstPtr) Line 1128 + 0xd bytes C
TKDraw.dll!TclpFindVariable(const char * name, int * lengthPtr) Line 677 + 0x17 bytes C
TKDraw.dll!TclGetEnv(const char * name, Tcl_DString * valuePtr) Line 479 + 0x12 bytes C
TKDraw.dll!TclFullFinalizationRequested() Line 733 + 0x11 bytes C
TKDraw.dll!Tcl_Exit(int status) Line 957 + 0x5 bytes C
TKDraw.dll!Draw_Interpretor::Destroy() Line 643 + 0x7 bytes C++
TKDraw.dll!Draw_Interpretor::~Draw_Interpretor() Line 125 + 0xa bytes C++
TKDraw.dll!`dynamic atexit destructor for 'theCommands''() + 0x21 bytes C++
TKDraw.dll!_CRT_INIT(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 415 C
TKDraw.dll!__DllMainCRTStartup(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 526 + 0x13 bytes C
TKDraw.dll!_DllMainCRTStartup(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 477 C

encoding and systemEncoding are NULL. src is "ADVISOR_XE_2013_DIR=C:\Program Files (x86)\Intel\Advisor XE 2013\"

I have tried different Tcl versions and i have compiled Tcl by my own. But there is always the same crash.

It crashes in release and debug mode.

How can i avoid this crash?

I am using windows 7 64-bit + VS2010.

Thanks in advance

Daniel Rudin's picture

Exactly the same problem here.. did you succeed in finding something?

Win7 64bit VS2008

thanks
Daniel

me_dulanga's picture

Same problem exists in OCC 6.8 also

Pradeep Rajan's picture

Has anybody found a solution yet?

Thanks

Joachim Greiner's picture

Has anybody found a solution for this problem? I am facing the same problem with OCCT 7.0.0. before upgrade to the new version everything worked fine with OCCT 6.9.0.

Thanks,

Joachim

Joachim Greiner's picture

The problem is solved when I compile OCCT 7.0.0. by using tcl 8.5!

Kirill Volyanskiy's picture

I have changed Tcl_Exit(0) to Tcl_Finalize() in 552 line of Draw_Interpretor.cxx and it resolved the problem.

Kirill Gavrilov's picture

From 5 years old attempt to replace Tcl_Exit() with Tcl_Finalize():

> It does not look like a patch fixes the problem - the application still crashes somewhere in tcl.dll at exit (can be seen only with attached debugger),
> thus it just postpones the place/time when the problem occurs. 

Don't know if this is the same in your case / has been improved with newer version of Tcl.

zhou zhuang's picture

I replaced Tcl_Exit() with Tcl_Finalize(),but it doesn't work,Is there any way to solve it

Kirill Volyanskiy's picture

I have OCCT 7.4.0 and Tcl 8.6. This solution has resolved my problem with the crashes. Debugger doesn't show it any more.

Kirill Volyanskiy's picture

I remember when I compiled OCCT without the DRAW module I had similar problem somewhere else but with the module it's been resolved.

zzj80902030_156995's picture

1、replace Tcl_Exit(0) with Tcl_Finalize() in Draw_Interpretor.cxx line 551

Draw_Interpretor::~Draw_Interpretor()
{
  SetDoLog (Standard_False);
  if (myFDLog >=0)
  {
    close (myFDLog);
    myFDLog = 0;
  }

  // MKV 01.02.05
#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)))
  try {
    OCC_CATCH_SIGNALS
	Tcl_Finalize(); //change here
  }
  catch (Standard_Failure const&) {
#ifdef OCCT_DEBUG
    std::cout <<"Tcl_Exit have an exeption" << std::endl;
#endif
  }
#else
#ifdef _WIN32
  Tcl_Exit(0);
#endif  
#endif
}

2、ignore tcl86.dll exception in visual studio ide

Marco Cecchi's picture

OCCT 7.4.0 with Tcl 8.6 here, and the problem persisted even by using Tcl_Finalize() all over.

I finally found a definitive fix by replacing the OCCT third party tcl/tk with IronTcl