Menu

#1999 SciTE hangs when searching for off-screen Lua labels

Bug
closed-fixed
5
2018-05-14
2018-03-04
Shao
No

SciTE Version 4.0.3 (Windows 7 64-bit)

  • Open a .lua file containing a label (e.g. ::mylabel::) somewhere below the initial viewable area.
  • Without scrolling the label into view, use Find to search for the label text.
  • SciTE hangs.

Discussion

  • Kein-Hong Man

    Kein-Hong Man - 2018-03-04

    This bug appears to be present pre-version 4 too. I can reproduce the behaviour. If label has been seen/lexed then there is no hang. There is no hang if I change the filename to use another lexer.

    I will trace some values in the LexLua label code and then report back.

     
  • Kein-Hong Man

    Kein-Hong Man - 2018-03-04

    Okay, in the label scanner (LexLua.cpp:134-172), commenting out the "skip over spaces/tabs" while loops eliminates the hang. So I am cautiously guessing that it may be an issue with the lexer runner. I will spend some time on this later today etc, but I am not quite fluent with stuff beyond the lexer(s).

    Instead of GetRelative(), perhaps I can/should use SafeGetCharAt() with a non-space 2nd argument.

     
  • Kein-Hong Man

    Kein-Hong Man - 2018-03-04

    So I think whatever the interaction between LexLua and its runner, the "skip over spaces/tabs" while loops are dangerous with the default 2nd argument of SafeGetCharAt(). My bad. I will have to change that. Probably get the end of line position and limit scanning to that range only.

     
  • Neil Hodgson

    Neil Hodgson - 2018-03-04

    Hi Kein-Hong,

    Its an infinite loop when skipping over the final "::". SciTE is asking for the range of the label text to be lexed which ends just before the "::". There is an sc.ForwardBytes(2) call to move past the "::" which calls Forward but it refuses to move forward as it is at the end of the range being lexed.

    While this could be avoided by forcing lexing to the line end (either in SciTE or Scintilla), its better to ensure ForwardBytes always returns by exiting its loop if calling Forward doesn't advance currentPos.

     
  • Kein-Hong Man

    Kein-Hong Man - 2018-03-04

    Oh OK, I assume you will change ForwardBytes?

    I will fix the "skip over spaces/tabs" while loops in LexLua, since they are an infinite loop risk too.

     
    • Neil Hodgson

      Neil Hodgson - 2018-03-04

      Yes, I'll fix ForwarBytes.

       
  • Neil Hodgson

    Neil Hodgson - 2018-03-04

    Proposed change to ForwardBytes

    diff -r aa859585e0c2 lexlib/StyleContext.h
    --- a/lexlib/StyleContext.h Sat Mar 03 14:17:28 2018 +1100
    +++ b/lexlib/StyleContext.h Mon Mar 05 07:55:24 2018 +1100
    @@ -131,7 +131,12 @@
        void ForwardBytes(Sci_Position nb) {
            const Sci_PositionU forwardPos = currentPos + nb;
            while (forwardPos > currentPos) {
    
    +           const Sci_PositionU currentPosStart = currentPos;
                Forward();
    +           if (currentPos == currentPosStart) {
    +               // Reached end
    +               return;
    +           }
            }
        }
        void ChangeState(int state_) {
    
     
  • Kein-Hong Man

    Kein-Hong Man - 2018-03-05

    Works for me. ForwardBytes() is only present in LexLua and LexPerl. I will check the code and also the whitespace scanning loops and report back this week, perhaps in a separate update ticket.

     
  • Neil Hodgson

    Neil Hodgson - 2018-03-05
    • labels: scite, lua --> scite, lua, scintilla, lexlib
    • status: open --> open-fixed
    • assigned_to: Neil Hodgson
     
  • Neil Hodgson

    Neil Hodgson - 2018-03-05

    Committed fix as [daf991].

    ForwardBytes was added with [00a8f3] by me in 2013.

     

    Related

    Commit: [00a8f3]
    Commit: [daf991]

  • Kein-Hong Man

    Kein-Hong Man - 2018-03-05

    Nothing else to change from me. No problem with forward scanning of whitespace, it will end when GetRelative() returns zeros. Guess I am feeling a bit paranoid. Instead I will shift to #1952 and try to get that done this week.

     
  • Neil Hodgson

    Neil Hodgson - 2018-05-14
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB