Re: Insight freezes on Windows 7

Fedin Pavel <[email protected]> Fri, 22 Mar 2013 13:31:31 +0400
Newsgroups gmane.comp.debugging.insight
Message-ID <[email protected]>
On 22.03.2013 12:00, Roland Schwingel wrote:
> >   I am trying to use Insight on Windows 7, and have problems. Under
> > certain conditions it freezes and GUI stops responding.
> I am a regular user of insight on Windows 7 64bit. I use insight both 
> for 32 and 64bit mingw targets and do not have hangs.
>
> I am not using open target but will try to reproduce this.
>
> Which tcl/tk version do you use? I am using a stock tcl/tk 8.6.0. All 
> versions before did had serious problems for me on windows 64bit. I am 
> quite happy with 8.6
  I have just checked out and built Insight. So i am using bundled 
version of tcl/tk.
  By this time i have found the reason for the problem. Opening a serial 
port inside TCL is tricky. I noticed that it uses overlapped mode, and 
also it creates separate thread for writing. Also looks like it 
registers the handle within main loop in order to support event-based 
reading (at least i expect it to be implemented in such a way). I have 
noticed that write implementation is very hacky (it uses 
TerminateThread() in order to stop the thread, which is not good at all).
  Currently i suggest that there is some mis-synchronization between 
this mechanism and main event loop which is triggered by quick 
open-close sequence. When i debugged the problem even a single printf() 
in C code after opening port handle appeared to cure it. Such behavior 
(and also the fact that on another machine it is not reproduced)  
usually clearly indicates some kind of races.
  Changing RWDR open mode to RDONLY fixes the problem. I will use this 
as a workaround, complete fix of TCL interpreter isn't my goal because 
i'm not going to use it outside of Insight.
  And one more note about port listing. It works incorrectly if your 
ports are not numbered in a sequence. This is quite normal situation 
with USB-Serial adapters which are quite widespread nowadays. For 
example, on my system i happen to have COM1, COM9 and COM10. Since i 
don't have COM5 the enumeration lists only COM1.
  I think it would be more correct to enumerate serial ports via 
registry or DeviceManager (or whatever it is called - i forgot) API. 
Unfortunately i totally forgot how to do it by now - i have done this 
once several years ago. But one can take a look at, for example,  
http://www.codeproject.com/Articles/14469/Simple-Device-Manager in order 
to learn how to do device enumeration on Windows.

-- 
  Kind regards
  Pavel Fedin
  Expert engineer, Samsung R&D Institute Rus