linux-awi / editra

Automatically exported from code.google.com/p/editra
Other
0 stars 0 forks source link

Editra hangs up when it reads a c file #558

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi.

I come across Editra hanging up.  It happened when Editra was reading a big 
file which has '.c' file extension. If the file extension is rewritten to other 
one as ".txt" then Editra read it without hanging up.

I attatched the file rctest.c

The rctest.c file is too big. and I found out the smallest file with which 
Editra hang up

I attatched the file test2.c

test2.c has only 13 bytes as below

data=open('test2.c', 'rb').read();[hex(ord(ch)) for ch in data]
===============================
['0x8b', '0x4e', '0x93', '0xae', '0x82', '0xaa', '0x82', '0xa9', '0x82', 
'0xa9', '0xd', '0xa', '0x0']

Hanging up will occur for any c file which includes any strings between 
['0x8b', '0x4e', '0x93', '0xae', '0x82', '0xaa', '0x82', '0xa9', '0x82', 
'0xa9', '0xd', '0xa'] and ['0x0']

----------------------------------
This hanging up will not occur if Editra reads a file which includes only 
alphabet characters. But Editra will hang up if it reads a file which includes 
['0x8b', '0x4e', '0x93', '0xae', '0x82', '0xaa', '0x82', '0xa9', '0x82', 
'0xa9', '0xd', '0xa'] and ['0x0'] non alphabet byte pattern.

It seem for Editra to hang up frequently if it read a file which includes non 
alphabet characters. Because It happened when I force Editra to read a big file 
at the first time.

----------------------------------
My Computer Environment

OS: Windows XP
Editr version:0.5.86
Python 2.6.4 -- EPD 6.1-1 (32-bit)

lobosKobayashi

Original issue reported on code.google.com by lobosKob...@gmail.com on 16 Nov 2010 at 3:56

Attachments:

GoogleCodeExporter commented 9 years ago
They both open just fine for me with no issue what so ever.

The text is not C code in either of the files so I am also a little confused as 
to why you said this is C?

What Plugins do you have installed and enabled?

Original comment by CodyPrec...@gmail.com on 16 Nov 2010 at 2:24

GoogleCodeExporter commented 9 years ago
Hi,

Sorry also what version of wxPython are you using? Unicode or Ansi Build? (see 
Help=>About in Editra).

Cody

Original comment by CodyPrec...@gmail.com on 16 Nov 2010 at 3:21

GoogleCodeExporter commented 9 years ago
I failed to notice this issue thread.

I replied directly for a mail that is sent to my mail address.
So I write the reply in this thread.

lobosKobayashi

================== content of the mail begin ==========================
I'm using wx Python in Enthought distribution: EPD 6.1-1 (32-bit)
I guess it might be unicode build because it reports as below.

---------------------------------------
About Editra 

Editra Version 0.5.86

Platform Info:(win32, python 2.6.4, wxMSW 2.8.10.1. unicode, wx-assertions-on 
SWIG-1.3.29)

import wx;wx.__version__
===============================
2.8.10.1

import wx;wx.PlatformInfo
===============================
('__WXMSW__', 'wxMSW', 'unicode', 'wx-assertions-on', 'SWIG-1.3.29')

python -u sfPP.py "import wx;help(wx)"
Help on package wx:

NAME
    wx

FILE
    d:\lng\python26\lib\site-packages\wx\__init__.py

DESCRIPTION
    #----------------------------------------------------------------------------
    # Name:         __init__.py
    # Purpose:      The presence of this file turns this directory into a
    #               Python package.
    #
    # Author:       Robin Dunn
    #
    # Created:      8-Aug-1998
    # RCS-ID:       $Id: __init__.py 43499 2006-11-18 21:23:43Z RD $
    # Copyright:    (c) 1998 by Total Control Software
    # Licence:      wxWindows license
    #----------------------------------------------------------------------------

PACKAGE CONTENTS
   .
   .

thanks for your usual kind replies

lobosKobayashi

================== content of the mail end ==========================

Original comment by lobosKob...@gmail.com on 18 Nov 2010 at 3:27

GoogleCodeExporter commented 9 years ago
>What Plugins do you have installed and enabled?

I attach EditrPluginSetting.jpg:a screen shot of the Editra plugin panel.

>They both open just fine for me with no issue what so ever.

So, I doubt that OS might be related to hanging up because I use windows XP 
Japanese version.

I test below sequence.

 * start    # execute cmd.exe
 * python -m pdb  D:\utl\Editra\Editra.py
 * c        # start Editra upon python debugger
 * menu -> alt F -> O -> "D:\my\vc7\mtCm\test2.c"

    Editra hangs up

 * ctrl + c # stop forcibly Editra

Python debugger report the trace back as below

------------- cmd.exe window begin ---------------
python -m pdb  D:\utl\Editra\Editra.py

D:\my\vc7\mtCm>python -m pdb  D:\utl\Editra\Editra.py
> d:\utl\editra\editra.py(16)<module>()
-> """
(Pdb) c
ConsoleCtrlHandler function failed*** Thu Nov 18 10:40:00 2010 ***
Traceback (most recent call last):
  File "D:\utl\Editra\src\ebmlib\osutil.py", line 50, in <lambda>
    win32api.SetConsoleCtrlHandler(lambda dummy : callback(*args, **kwargs),
TypeError: Exit() takes at most 2 arguments (3 given)
------------- cmd.exe window end ---------------

I attach EditrHangingUp.jpg:the full screen shot on my computer display.

>The text is not C code in either of the files so I am also a little confused 
as to why you said this is C?

I used to record small C test code blocks into a file:"rctest.c". So I record 
small test code blocks into a rctest.c file in each directory though their 
codes are not c codes.  In Editra directoryI record test python codes into 
rctest.c that I attached in Nov 15 article. I attach a old rctest.c file which 
includes only c code blocks as a example.

lobosKobayashi

Original comment by lobosKob...@gmail.com on 18 Nov 2010 at 3:28

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,

I guess I am a little stumped at the moment. My system configuration is almost 
identical to yours.

Have you tried with your console plugin completely removed?

How are you opening the file? (File dialog, Filebrowser, drag and drop, some 
other way?)

I just fixed the error that was shown from your debug session above. It is 
unrelated to the lock up though.

Original comment by CodyPrec...@gmail.com on 18 Nov 2010 at 4:37

GoogleCodeExporter commented 9 years ago
Hi

>Have you tried with your console plugin completely removed?

No, I only disable my egg files.

So I tried to remove my egg files from Editra\plugin directory. But Editra 
hangs up for test2.c once again. I attach the Editra Plugin Manager screen shot.

>How are you opening the file? (File dialog, Filebrowser, drag and drop, some 
other way?)

I open the file from Menu:
   alt + F -> O -> windows open dialog -> set "D:\my\vc7\mtCm\test2.c -> OK

----------------------
I determined the line where Editra hang up.

I inserted debugger break line at src\ed_main.py:line 593, and started Editra 
by "python -m pdb  D:\utl\Editra\Editra.py" and do c:continue command in python 
debugger.

    def OnOpen(self, evt):
        """Open a File
        @param evt: Event fired that called this handler
        @type evt: wxMenuEvent

        """
        if evt.GetId() == ID_OPEN:
            import pdb; pdb.set_trace() # 10.11.18 kobayashi <==
            self.DoOpen(evt)
        else:
            evt.Skip()

After breaking under debugger at ed_main.py:line 953, the do the n:next 
commands until hang up. "self.DoOpen(evt)" doesn't hang up and windows open 
file dialog is executed.

So I continued n:next commands. Editra hanged up at the below line

> d:\utl\editra\src\ed_stc.py(828)OnUpdateUI()
-> evt.Skip()

I tried once more and I traced by s:skip command from ed_stc.py(828). Editra 
hang upped at lib\site-packages\wx\stc.py(5380)<lambda>() as below

> d:\utl\editra\src\ed_stc.py(828)OnUpdateUI()->None
-> evt.Skip()
(Pdb) l
823                 self.DoBraceHighlight()
824
825             # XXX: handle when column mode is enabled
826             if self.VertEdit.Enabled:
827                 self.VertEdit.OnUpdateUI(evt)
828  ->         evt.Skip()
829
830         def OnUserListSel(self, evt):
831             """Callback hook for userlist selections"""
832             mdata = dict(ltype=evt.GetListType(),
833                          text=evt.GetText(),
(Pdb) s
--Call--
> d:\lng\python26\lib\site-packages\wx\stc.py(5380)<lambda>()
-> __del__ = lambda self : None;
(Pdb) l
5375        __repr__ = _swig_repr
5376        def __init__(self, *args, **kwargs):
5377            """__init__(self, EventType commandType=0, int id=0) -> StyledTe
xtEvent"""
5378            _stc.StyledTextEvent_swiginit(self,_stc.new_StyledTextEvent(*arg
s, **kwargs))
5379        __swig_destroy__ = _stc.delete_StyledTextEvent
5380 ->     __del__ = lambda self : None;
5381        def SetPosition(*args, **kwargs):
5382            """SetPosition(self, int pos)"""
5383            return _stc.StyledTextEvent_SetPosition(*args, **kwargs)
5384
5385        def SetKey(*args, **kwargs):
(Pdb) n
> d:\lng\python26\lib\site-packages\wx\stc.py(5380)<lambda>()
-> __del__ = lambda self : None;
(Pdb)
--Return--
> d:\lng\python26\lib\site-packages\wx\stc.py(5380)<lambda>()->None
-> __del__ = lambda self : None;
(Pdb)

----------------------
I attached trace_hangup.txt:the debugger tracing text. I hope the text file is 
helpful.

Original comment by lobosKob...@gmail.com on 18 Nov 2010 at 6:57

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,

This trace is rather strange. It looks like its in the UpdateUI handler in my 
subclass but the frame in the base stc class is showing its in its __del__ 
method. Which would make me think that the event is being handled while the 
object is being destroyed.

Does it behave any differently if you comment out the 'evt.Skip()' or don't 
Bind the EVT_STC_UPDATEUI event in the ed_stc class?

Original comment by CodyPrec...@gmail.com on 18 Nov 2010 at 3:09

GoogleCodeExporter commented 9 years ago
Hi

>Does it behave any differently if you comment out the 'evt.Skip()' 
I guess "evt.Skip()" might be in OnUpdateUI(..).

    def OnUpdateUI(self, evt):
        """Check for matching braces
        @param evt: event that called this handler
        @type evt: wx.stc.StyledTextEvent

        """
        # If disabled just skip the event
        if self._config['brackethl']:
            self.DoBraceHighlight()

        # XXX: handle when column mode is enabled
        if self.VertEdit.Enabled:
            self.VertEdit.OnUpdateUI(evt)
        #evt.Skip()                             #<== comment out

I tried 
 * comment out the evt.Skip()
 * alt+F --> O and D:\my\vc7\mtCm\test2.c

But Editra hanged upp once again. I traced from self.DoOpen(evt) to determine 
the line where Editra hanged up

The result is below. The details are in trace_evSkip.txt attached file.

> d:\utl\editra\src\ed_stc.py(826)OnUpdateUI()->None
-> if self.VertEdit.Enabled:        <== hung up

---------------------------
>or don't Bind the EVT_STC_UPDATEUI event in the ed_stc class? 

I tried 
 * comment out the OnUserListSel() Bind
 * alt+F --> O and D:\my\vc7\mtCm\test2.c

        self.Bind(wx.stc.EVT_STC_MARGINCLICK, self.OnMarginClick)
        #self.Bind(wx.stc.EVT_STC_UPDATEUI, self.OnUpdateUI)        #<== comment out
        self.Bind(wx.stc.EVT_STC_USERLISTSELECTION, self.OnUserListSel)
        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
        self.Bind(wx.EVT_CHAR, self.OnChar)
        self.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
        self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
        self.Bind(wx.EVT_TIMER, self.OnBackupTimer)

But Editra hanged upp once again. I traced from self.DoOpen(evt) to determine 
the line where Editra hanged up

The result is below. The details are in hangup_Omit_OnUpdateUI.txt.txt attached 
file.

> d:\utl\editra\src\extern\aui\framemanager.py(8639)OnPaint()->None
-> self.Repaint(dc)
(Pdb)

lobosKobayashi

Original comment by lobosKob...@gmail.com on 19 Nov 2010 at 1:59

Attachments:

GoogleCodeExporter commented 9 years ago
I don't think the problem is this area. The stack traces just seem to point to 
it locking up while the screen is being redrawn, but changes randomly as parts 
of the code are removed.

My thoughts would be that the lockup is on another thread but if you have 
disabled all the plugins and are opening a file that is less than 1MB in size 
there should only be two threads running. The main GUI thread and then a thread 
for the IPC server. The IPC server thread doesn't interact with the gui in 
anyway so it shouldn't be causing any issue. It can be disabled by starting 
Editra with the -S option. 'Editra -S'.

Still not sure why I can't reproduce this issue on my machines and why you can 
do it every time. 

Original comment by CodyPrec...@gmail.com on 19 Nov 2010 at 3:04

GoogleCodeExporter commented 9 years ago
Hi

>It can be disabled by starting Editra with the -S option. 'Editra -S'.

I tried "python -m pdb D:\utl\Editra\Editra.py -S" and make Editra read 
test2.c. And Editra hanged up again at the "__del__ = lambda self : None;". 

I attached the traced result:hangup_With_S_option.txt

------------------
>Still not sure why I can't reproduce this issue on my machines and why you can 
do it every time. 

I'm doubting a combination of Windows XP Japanese version and kanji code and 
wx.stc.StyledTextCtrl at analyzing the text for folding because

* test2.c data ['0x8b', '0x4e', '0x93', '0xae', '0x82', '0xaa', '0x82', '0xa9', 
'0x82', '0xa9'" is kanji code.
* if I rename test2.c to test2 then Editra doesn't hang up although the data 
pattern is same.
* Windows XP Japanese version use kanji characters for the returned strings to 
commands.
* wx.stc.StyledTextCtrl brings on many problems for kanji characters.

It is a time spending work to analyze C source codes to get data for folding. 
So Scintilla will use another thread and multi-thread programming is 
troublesome. I agree with you there might be some thread related problems.

lobosKobayashi

Original comment by lobosKob...@gmail.com on 20 Nov 2010 at 4:32

Attachments:

GoogleCodeExporter commented 9 years ago
Testing with latest 0.6.0 version and am unable to reproduce the issue. The 
file loads without locking up Editra.

Closing this issue for now. If you are still having issues in 0.6.0 feel free 
to reopen and further investigation can be attempted.

Original comment by CodyPrec...@gmail.com on 28 Jan 2011 at 9:06