View Issue Details

IDProjectCategoryView StatusLast Update
0035958LazarusPackagespublic2019-08-16 12:48
ReporterOndrej PokornyAssigned ToMartin Friebe 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformOSWindowsOS Version10
Product Version2.1 (SVN)Product Build 
Target VersionFixed in Version2.0.6 
Summary0035958: Internal error in TSynCustomFoldHighlighter
DescriptionWhen saving a new unit for a package, I get the following exception and Lazarus IDE crashes:

TSynCustomFoldHighlighter.FoldBlockEndLevel requires CurrentRanges (synhighlighterpas.pp, line 3453).

Press OK to ignore and risk data corruption.
Press Abort to kill the program.
Steps To Reproduce1.) Start Lazarus.
2.) Open a new project.
3.) Open some package.
4.) In the package dialog, click on the Add button, from the drop down menu pick up "New File".
5.) Save the file under a new name.
6.) The Exception dialog pops up and Lazarus crashes.
TagsNo tags attached.
Fixed in Revision61697
LazTarget2.0.6
Widgetset
Attached Files
  • Exception.png (7,205 bytes)
    Exception.png (7,205 bytes)
  • CurrentRanges.Assert.StackTrace.txt (5,870 bytes)
    #0 fpc_raiseexception(0x1598bd8, 0x1598bc0, 0xd7d) at ..\inc\except.inc:163
    #1 ASSERTERRORHANDLER('TSynCustomFoldHighlighter'..., 'synhighlighterpas.pp', 3453, 0x1426ec68) at ..\objpas\sysutils\sysutils.inc:488
    #2 fpc_assert('TSynCustomFoldHighlighter'..., 'synhighlighterpas.pp', 3453, 0x1426ec68) at ..\inc\system.inc:1565
    #3 FOLDBLOCKENDLEVEL(0x24fa86d0, -1, {FOLDGROUP = 1, FLAGS = [SFBINCLUDEDISABLED]}) at synhighlighterpas.pp:3453
    #4 FOLDBLOCKENDLEVEL(0x24fa86d0, -1, 1, [SFBINCLUDEDISABLED]) at synedithighlighterfoldbase.pas:1843
    #5 INITCOUNT(0x234abcf0) at synedithighlighterfoldbase.pas:1475
    #6 COUNT(0x234abcf0) at synedithighlighterfoldbase.pas:1674
    #7 SRCSYNCARETCHANGED(0x1f303360, 0x0) at sourcesyneditor.pas:1469
    #8 DOONSTATUSCHANGE(0x1f303360, [SCLINESINWINDOW]) at sourcesyneditor.pas:1555
    #9 DODECPAINTLOCK(0x1f303360, 0x1f303360) at synedit.pp:2501
    #10 CALLNOTIFYEVENTS(0x236ff020, 0x1f303360) at lazmethodlist.pas:315
    #11 SENDNOTIFICATION(0x14365540, SENRDECPAINTLOCK, 0x1f303360) at synedittextbuffer.pp:1564
    #12 SETUPDATESTATE(0x14365540, false, 0x1f303360) at synedittextbuffer.pp:1267
    #13 ENDUPDATE(0x14365540, 0x1f303360) at lazsynedittext.pas:978
    #14 DECPAINTLOCK(0x1f303360) at synedit.pp:2387
    #15 SETHIGHLIGHTER(0x1f303360, 0x24ce2a20) at synedit.pp:6417
    #16 SETHIGHLIGHTER(0x1f303360, 0x24ce2a20) at sourcesyneditor.pas:1713
    #17 SETSYNTAXHIGHLIGHTERTYPE(0x22b8c598, LSHFREEPASCAL) at sourceeditor.pp:4890
    #18 RENAMEUNIT(0x18d45bf0, 0x2345cb24 'P:\programs\lazarus'..., 0x238c1b6c 'OPopupForm', 0x0, 0x0) at sourcefilemanager.pas:5460
    #19 SHOWSAVEFILEASDIALOG(0x236fd32c 'unit2.pas', 0x18d45bf0, 0x0, 0x0, false) at sourcefilemanager.pas:4721
    #20 SAVEEDITORFILE(0x22b8c598, [SFSAVEAS, SFCHECKAMBIGUOUSFILES]) at sourcefilemanager.pas:2487
    #21 DOSAVEEDITORFILE(0x1433e058, 0x22b8c598, [SFCHECKAMBIGUOUSFILES]) at main.pp:5862
    #22 MNUSAVECLICKED(0x1433e058, 0x1433e058) at main.pp:3341
    #23 PROCESSIDECOMMAND(0x1433e058, 0x24fa1810, 1208, true) at main.pp:3538
    #24 PROCESSPARENTCOMMAND(0x24fa1810, 0x22b8c598, 1208, '', 0x0, true) at sourceeditor.pp:8833
    #25 PROCESSUSERCOMMAND(0x22b8c598, 0x1f303360, 1208, '', 0x0) at sourceeditor.pp:4203
    #26 DOONPROCESSCOMMAND(0x1f303360, 1208, '', 0x0) at synedit.pp:7261
    #27 COMMANDPROCESSOR(0x1f303360, 1208, '', 0x0, []) at synedit.pp:6607
    #28 KEYDOWN(0x1f303360, 0, [SSCTRL]) at synedit.pp:3006
    #29 KEYDOWNBEFOREINTERFACE(0x1f303360, 0, [SSCTRL]) at include\wincontrol.inc:5685
    #30 DOKEYDOWNBEFOREINTERFACE(0x1f303360, {MSG = 48384, CHARCODE = 0, UNUSED = 0, KEYDATA = 2031617, RESULT = 0}, false) at include\wincontrol.inc:5816
    #31 CNKEYDOWN(0x1f303360, {MSG = 48384, CHARCODE = 0, UNUSED = 0, KEYDATA = 2031617, RESULT = 0}) at include\wincontrol.inc:7205
    #32 DISPATCH(0x1f303360, 0) at ..\inc\objpas.inc:684
    #33 WNDPROC(0x1f303360, {MSG = 48384, WPARAM = 0, LPARAM = 2031617, RESULT = 0, WPARAMLO = 0, WPARAMHI = 0, WPARAMFILLER = {}, LPARAMLO = 1, LPARAMHI = 31, LPARAMFILLER = {}, RESULTLO = 0, RESULTHI = 0, RESULTFILLER = {}}) at include\control.inc:2242
    #34 WNDPROC(0x1f303360, {MSG = 48384, WPARAM = 0, LPARAM = 2031617, RESULT = 0, WPARAMLO = 0, WPARAMHI = 0, WPARAMFILLER = {}, LPARAMLO = 1, LPARAMHI = 31, LPARAMFILLER = {}, RESULTLO = 0, RESULTHI = 0, RESULTFILLER = {}}) at include\wincontrol.inc:5412
    #35 WNDPROC(0x1f303360, {MSG = 48384, WPARAM = 0, LPARAM = 2031617, RESULT = 0, WPARAMLO = 0, WPARAMHI = 0, WPARAMFILLER = {}, LPARAMLO = 1, LPARAMHI = 31, LPARAMFILLER = {}, RESULTLO = 0, RESULTHI = 0, RESULTFILLER = {}}) at synedit.pp:6188
    #36 DELIVERMESSAGE(0x1f303360, 0) at lclmessageglue.pas:112
    #37 DOWINDOWPROC({WINDOW = 591444, MSG = 256, WPARAM = 83, LPARAM = 2031617, LMESSAGE = {MSG = 0, WPARAM = 0, LPARAM = 0, RESULT = 0, WPARAMLO = 0, WPARAMHI = 0, WPARAMFILLER = {}, LPARAMLO = 0, LPARAMHI = 0, LPARAMFILLER = {}, RESULTLO = 0, RESULTHI = 0, RESULTFILLER = {}}, PLMSG = 0x1426fa6c, LWINCONTROL = 0x1f303360, WINPROCESS = false, NOTIFYUSERINPUT = true, WINDOWINFO = 0x2354d7a8, BACKUPBUFFER = {DC = 0, BITMAP = 0, BITMAPWIDTH = 0, BITMAPHEIGHT = 0}, WINDOWWIDTH = 0, WINDOWHEIGHT = 0, PAINTMSG = {MSG = 0, DC = 0, PAINTSTRUCT = 0x0, RESULT = 0}, RTLLAYOUT = false, ORGCHARCODE = 0, LMSCROLL = {MSG = 0, SCROLLCODE = 0, SMALLPOS = 0, SCROLLBAR = 0, RESULT = 0, POS = 0}, LMKEY = {MSG = 48384, CHARCODE = 0, UNUSED = 0, KEYDATA = 2031617, RESULT = 0}, LMCHAR = {MSG = 0, CHARCODE = 0, UNUSED = 0, KEYDATA = 0, RESULT = 0}, LMMOUSE = {MSG = 0, KEYS = 0, XPOS = 0, YPOS = 0, POS = {X = 0, Y = 0}, DUMMY = 0, RESULT = 0}, LMCONTEXTMENU = {MSG = 0, HWND = 0, XPOS = 0, YPOS = 0, POS = {X = 0, Y = 0}, DUMMY = 0, RESULT = 0}, LMMOUSEMOVE = {MSG = 0, KEYS = 0, XPOS = 0, YPOS = 0, POS = {X = 0, Y = 0}, DUMMY = 0, RESULT = 0}, LMMOUSEEVENT = {MSG = 0, BUTTON = 0, WHEELDELTA = 0, X = 0, Y = 0, RESULT = 0, USERDATA = 0x0, STATE = []}, LMMOVE = {MSG = 0, MOVETYPE = 0, XPOS = 0, YPOS = 0, POS = {X = 0, Y = 0}, DUMMY = 0, RESULT = 0}, LMNOTIFY = {MSG = 0, IDCTRL = 0, NMHDR = 0x0, RESULT = 0}, DRAWLISTITEMSTRUCT = {ITEMID = 0, AREA = {LEFT = 0, TOP = 0, RIGHT = 0, BOTTOM = 0, TOPLEFT = {X = 0, Y = 0}, BOTTOMRIGHT = {X = 0, Y = 0}, VECTOR = {0, 0, 0, 0}}, DC = 0, ITEMSTATE = []}, NMHDR = 0x1f0001}) at win32\win32callback.inc:2516
    #38 WINDOWPROC(591444, 256, 83, 2031617) at win32\win32callback.inc:2677
    #39 USER32!AddClipboardFormatListener at :0
    #40 USER32!CallWindowProcW at :0
    #41 USER32!DispatchMessageW at :0
    #42 USER32!DispatchMessageW at :0
    #43 APPPROCESSMESSAGES(0x1433de58) at win32\win32object.inc:407
    #44 HANDLEMESSAGE(0x142d6298) at include\application.inc:1282
    #45 RUNLOOP(0x142d6298) at include\application.inc:1419
    #46 APPRUN(0x1433de58, {Proc = {procedure (POINTER)} 0x1426fed4, Self = 0x142d6298}) at include\interfacebase.inc:54
    #47 RUN(0x142d6298) at include\application.inc:1407
    #48 main at lazarus.pp:152
    
  • synhighlighterpas-01.patch (661 bytes)
    Index: components/synedit/synhighlighterpas.pp
    ===================================================================
    --- components/synedit/synhighlighterpas.pp	(revision 61686)
    +++ components/synedit/synhighlighterpas.pp	(working copy)
    @@ -3450,8 +3450,10 @@
       inf: TSynPasRangeInfo;
       r, r2: Pointer;
     begin
    -  Assert(CurrentRanges <> nil, 'TSynCustomFoldHighlighter.FoldBlockEndLevel requires CurrentRanges');
    +  //Assert(CurrentRanges <> nil, 'TSynCustomFoldHighlighter.FoldBlockEndLevel requires CurrentRanges');
       Result := 0;
    +  if CurrentRanges=nil then
    +    Exit;
       inf.EndLevelIfDef := 0;
       inf.MinLevelIfDef := 0;
       inf.EndLevelRegion := 0;
    
  • syn_hl_ranges.diff (2,080 bytes)
    diff --git "a/ide/sourcesyneditor.pas" "b/ide/sourcesyneditor.pas"
    index 886b05fb9a..a3fca89b63 100644
    --- "a/ide/sourcesyneditor.pas"
    +++ "b/ide/sourcesyneditor.pas"
    @@ -1708,29 +1708,34 @@ begin
         exit
       end;
     
    -  FMarkupIfDef.Highlighter := nil;
    +  IncPaintLock;
    +  try
    +    FMarkupIfDef.Highlighter := nil;
     
    -  inherited SetHighlighter(Value);
    +    inherited SetHighlighter(Value);
     
    -//TSynEditMarkupFoldColors(MarkupByClass[TSynEditMarkupFoldColors]).Highlighter := Highlighter; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    -  if Highlighter is TSynPasSyn then
    -    FMarkupIfDef.Highlighter := TSynPasSyn(Highlighter)
    -  else
    -    FMarkupIfDef.Highlighter := nil;
    +    //TSynEditMarkupFoldColors(MarkupByClass[TSynEditMarkupFoldColors]).Highlighter := Highlighter; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    +    if Highlighter is TSynPasSyn then
    +      FMarkupIfDef.Highlighter := TSynPasSyn(Highlighter)
    +    else
    +      FMarkupIfDef.Highlighter := nil;
     
    -  if Highlighter is TSynCustomFoldHighlighter then
    -    FTopInfoNestList.Highlighter := TSynCustomFoldHighlighter(Highlighter)
    -  else
    -    FTopInfoNestList.Highlighter := nil;
    +    if Highlighter is TSynCustomFoldHighlighter then
    +      FTopInfoNestList.Highlighter := TSynCustomFoldHighlighter(Highlighter)
    +    else
    +      FTopInfoNestList.Highlighter := nil;
     
    -  if FUserWordsList = nil then
    -    exit;
    -  if Highlighter <> nil then
    -    for i := 0 to FUserWordsList.Count - 1 do
    -      HighlightUserWords[i].WordBreakChars := Highlighter.WordBreakChars + TSynWhiteChars
    -  else
    -    for i := 0 to FUserWordsList.Count - 1 do
    -      HighlightUserWords[i].ResetWordBreaks;
    +    if FUserWordsList = nil then
    +      exit;
    +    if Highlighter <> nil then
    +      for i := 0 to FUserWordsList.Count - 1 do
    +        HighlightUserWords[i].WordBreakChars := Highlighter.WordBreakChars + TSynWhiteChars
    +    else
    +      for i := 0 to FUserWordsList.Count - 1 do
    +        HighlightUserWords[i].ResetWordBreaks;
    +  finally
    +    DecPaintLock;
    +  end;
     end;
     
     constructor TIDESynEditor.Create(AOwner: TComponent);
    
    syn_hl_ranges.diff (2,080 bytes)

Activities

Ondrej Pokorny

2019-08-12 16:13

reporter  

Exception.png (7,205 bytes)
Exception.png (7,205 bytes)

Ondrej Pokorny

2019-08-12 16:18

reporter   ~0117653

Stack trace is attached

CurrentRanges.Assert.StackTrace.txt (5,870 bytes)
#0 fpc_raiseexception(0x1598bd8, 0x1598bc0, 0xd7d) at ..\inc\except.inc:163
#1 ASSERTERRORHANDLER('TSynCustomFoldHighlighter'..., 'synhighlighterpas.pp', 3453, 0x1426ec68) at ..\objpas\sysutils\sysutils.inc:488
#2 fpc_assert('TSynCustomFoldHighlighter'..., 'synhighlighterpas.pp', 3453, 0x1426ec68) at ..\inc\system.inc:1565
#3 FOLDBLOCKENDLEVEL(0x24fa86d0, -1, {FOLDGROUP = 1, FLAGS = [SFBINCLUDEDISABLED]}) at synhighlighterpas.pp:3453
#4 FOLDBLOCKENDLEVEL(0x24fa86d0, -1, 1, [SFBINCLUDEDISABLED]) at synedithighlighterfoldbase.pas:1843
#5 INITCOUNT(0x234abcf0) at synedithighlighterfoldbase.pas:1475
#6 COUNT(0x234abcf0) at synedithighlighterfoldbase.pas:1674
#7 SRCSYNCARETCHANGED(0x1f303360, 0x0) at sourcesyneditor.pas:1469
#8 DOONSTATUSCHANGE(0x1f303360, [SCLINESINWINDOW]) at sourcesyneditor.pas:1555
#9 DODECPAINTLOCK(0x1f303360, 0x1f303360) at synedit.pp:2501
#10 CALLNOTIFYEVENTS(0x236ff020, 0x1f303360) at lazmethodlist.pas:315
#11 SENDNOTIFICATION(0x14365540, SENRDECPAINTLOCK, 0x1f303360) at synedittextbuffer.pp:1564
#12 SETUPDATESTATE(0x14365540, false, 0x1f303360) at synedittextbuffer.pp:1267
#13 ENDUPDATE(0x14365540, 0x1f303360) at lazsynedittext.pas:978
#14 DECPAINTLOCK(0x1f303360) at synedit.pp:2387
#15 SETHIGHLIGHTER(0x1f303360, 0x24ce2a20) at synedit.pp:6417
#16 SETHIGHLIGHTER(0x1f303360, 0x24ce2a20) at sourcesyneditor.pas:1713
#17 SETSYNTAXHIGHLIGHTERTYPE(0x22b8c598, LSHFREEPASCAL) at sourceeditor.pp:4890
#18 RENAMEUNIT(0x18d45bf0, 0x2345cb24 'P:\programs\lazarus'..., 0x238c1b6c 'OPopupForm', 0x0, 0x0) at sourcefilemanager.pas:5460
#19 SHOWSAVEFILEASDIALOG(0x236fd32c 'unit2.pas', 0x18d45bf0, 0x0, 0x0, false) at sourcefilemanager.pas:4721
#20 SAVEEDITORFILE(0x22b8c598, [SFSAVEAS, SFCHECKAMBIGUOUSFILES]) at sourcefilemanager.pas:2487
#21 DOSAVEEDITORFILE(0x1433e058, 0x22b8c598, [SFCHECKAMBIGUOUSFILES]) at main.pp:5862
#22 MNUSAVECLICKED(0x1433e058, 0x1433e058) at main.pp:3341
#23 PROCESSIDECOMMAND(0x1433e058, 0x24fa1810, 1208, true) at main.pp:3538
#24 PROCESSPARENTCOMMAND(0x24fa1810, 0x22b8c598, 1208, '', 0x0, true) at sourceeditor.pp:8833
#25 PROCESSUSERCOMMAND(0x22b8c598, 0x1f303360, 1208, '', 0x0) at sourceeditor.pp:4203
#26 DOONPROCESSCOMMAND(0x1f303360, 1208, '', 0x0) at synedit.pp:7261
#27 COMMANDPROCESSOR(0x1f303360, 1208, '', 0x0, []) at synedit.pp:6607
#28 KEYDOWN(0x1f303360, 0, [SSCTRL]) at synedit.pp:3006
#29 KEYDOWNBEFOREINTERFACE(0x1f303360, 0, [SSCTRL]) at include\wincontrol.inc:5685
#30 DOKEYDOWNBEFOREINTERFACE(0x1f303360, {MSG = 48384, CHARCODE = 0, UNUSED = 0, KEYDATA = 2031617, RESULT = 0}, false) at include\wincontrol.inc:5816
#31 CNKEYDOWN(0x1f303360, {MSG = 48384, CHARCODE = 0, UNUSED = 0, KEYDATA = 2031617, RESULT = 0}) at include\wincontrol.inc:7205
#32 DISPATCH(0x1f303360, 0) at ..\inc\objpas.inc:684
#33 WNDPROC(0x1f303360, {MSG = 48384, WPARAM = 0, LPARAM = 2031617, RESULT = 0, WPARAMLO = 0, WPARAMHI = 0, WPARAMFILLER = {}, LPARAMLO = 1, LPARAMHI = 31, LPARAMFILLER = {}, RESULTLO = 0, RESULTHI = 0, RESULTFILLER = {}}) at include\control.inc:2242
#34 WNDPROC(0x1f303360, {MSG = 48384, WPARAM = 0, LPARAM = 2031617, RESULT = 0, WPARAMLO = 0, WPARAMHI = 0, WPARAMFILLER = {}, LPARAMLO = 1, LPARAMHI = 31, LPARAMFILLER = {}, RESULTLO = 0, RESULTHI = 0, RESULTFILLER = {}}) at include\wincontrol.inc:5412
#35 WNDPROC(0x1f303360, {MSG = 48384, WPARAM = 0, LPARAM = 2031617, RESULT = 0, WPARAMLO = 0, WPARAMHI = 0, WPARAMFILLER = {}, LPARAMLO = 1, LPARAMHI = 31, LPARAMFILLER = {}, RESULTLO = 0, RESULTHI = 0, RESULTFILLER = {}}) at synedit.pp:6188
#36 DELIVERMESSAGE(0x1f303360, 0) at lclmessageglue.pas:112
#37 DOWINDOWPROC({WINDOW = 591444, MSG = 256, WPARAM = 83, LPARAM = 2031617, LMESSAGE = {MSG = 0, WPARAM = 0, LPARAM = 0, RESULT = 0, WPARAMLO = 0, WPARAMHI = 0, WPARAMFILLER = {}, LPARAMLO = 0, LPARAMHI = 0, LPARAMFILLER = {}, RESULTLO = 0, RESULTHI = 0, RESULTFILLER = {}}, PLMSG = 0x1426fa6c, LWINCONTROL = 0x1f303360, WINPROCESS = false, NOTIFYUSERINPUT = true, WINDOWINFO = 0x2354d7a8, BACKUPBUFFER = {DC = 0, BITMAP = 0, BITMAPWIDTH = 0, BITMAPHEIGHT = 0}, WINDOWWIDTH = 0, WINDOWHEIGHT = 0, PAINTMSG = {MSG = 0, DC = 0, PAINTSTRUCT = 0x0, RESULT = 0}, RTLLAYOUT = false, ORGCHARCODE = 0, LMSCROLL = {MSG = 0, SCROLLCODE = 0, SMALLPOS = 0, SCROLLBAR = 0, RESULT = 0, POS = 0}, LMKEY = {MSG = 48384, CHARCODE = 0, UNUSED = 0, KEYDATA = 2031617, RESULT = 0}, LMCHAR = {MSG = 0, CHARCODE = 0, UNUSED = 0, KEYDATA = 0, RESULT = 0}, LMMOUSE = {MSG = 0, KEYS = 0, XPOS = 0, YPOS = 0, POS = {X = 0, Y = 0}, DUMMY = 0, RESULT = 0}, LMCONTEXTMENU = {MSG = 0, HWND = 0, XPOS = 0, YPOS = 0, POS = {X = 0, Y = 0}, DUMMY = 0, RESULT = 0}, LMMOUSEMOVE = {MSG = 0, KEYS = 0, XPOS = 0, YPOS = 0, POS = {X = 0, Y = 0}, DUMMY = 0, RESULT = 0}, LMMOUSEEVENT = {MSG = 0, BUTTON = 0, WHEELDELTA = 0, X = 0, Y = 0, RESULT = 0, USERDATA = 0x0, STATE = []}, LMMOVE = {MSG = 0, MOVETYPE = 0, XPOS = 0, YPOS = 0, POS = {X = 0, Y = 0}, DUMMY = 0, RESULT = 0}, LMNOTIFY = {MSG = 0, IDCTRL = 0, NMHDR = 0x0, RESULT = 0}, DRAWLISTITEMSTRUCT = {ITEMID = 0, AREA = {LEFT = 0, TOP = 0, RIGHT = 0, BOTTOM = 0, TOPLEFT = {X = 0, Y = 0}, BOTTOMRIGHT = {X = 0, Y = 0}, VECTOR = {0, 0, 0, 0}}, DC = 0, ITEMSTATE = []}, NMHDR = 0x1f0001}) at win32\win32callback.inc:2516
#38 WINDOWPROC(591444, 256, 83, 2031617) at win32\win32callback.inc:2677
#39 USER32!AddClipboardFormatListener at :0
#40 USER32!CallWindowProcW at :0
#41 USER32!DispatchMessageW at :0
#42 USER32!DispatchMessageW at :0
#43 APPPROCESSMESSAGES(0x1433de58) at win32\win32object.inc:407
#44 HANDLEMESSAGE(0x142d6298) at include\application.inc:1282
#45 RUNLOOP(0x142d6298) at include\application.inc:1419
#46 APPRUN(0x1433de58, {Proc = {procedure (POINTER)} 0x1426fed4, Self = 0x142d6298}) at include\interfacebase.inc:54
#47 RUN(0x142d6298) at include\application.inc:1407
#48 main at lazarus.pp:152

Ondrej Pokorny

2019-08-12 16:28

reporter   ~0117654

A simple workaround that fixes the issue for me is attached. (Just a replacement with Exit.)

synhighlighterpas-01.patch (661 bytes)
Index: components/synedit/synhighlighterpas.pp
===================================================================
--- components/synedit/synhighlighterpas.pp	(revision 61686)
+++ components/synedit/synhighlighterpas.pp	(working copy)
@@ -3450,8 +3450,10 @@
   inf: TSynPasRangeInfo;
   r, r2: Pointer;
 begin
-  Assert(CurrentRanges <> nil, 'TSynCustomFoldHighlighter.FoldBlockEndLevel requires CurrentRanges');
+  //Assert(CurrentRanges <> nil, 'TSynCustomFoldHighlighter.FoldBlockEndLevel requires CurrentRanges');
   Result := 0;
+  if CurrentRanges=nil then
+    Exit;
   inf.EndLevelIfDef := 0;
   inf.MinLevelIfDef := 0;
   inf.EndLevelRegion := 0;

Martin Friebe

2019-08-14 17:05

manager   ~0117671

The assert is correct. At that point a pascal highlighter must have ranges. If it does not, something else went wrong before.

I can not get the crash to happen with the steps provided (2.1 / 3.0.4 on Win10)
I can not even get similar stacktraces, by setting breakpoints at the same places.
0000018 RENAMEUNIT(0x18d45bf0, 0x2345cb24 'P:\programs\lazarus'..., 0x238c1b6c 'OPopupForm', 0x0, 0x0) at sourcefilemanager.pas:5460
Does not seem to change the HL for me.

In order to get anywhere close to that, I can "Add > New Flie" Text file. Then when saving rename to .pas.
But while that triggers SetHighlighter from inside RENAMEUNIT, it does not trigger the TIDESynEditor.SrcSynCaretChanged. So I still do not even get the same flow that you get.

---
What I noted (If I read the trace correct)

0000015 SETHIGHLIGHTER(0x1f303360, 0x24ce2a20) at synedit.pp:6417
The new highlighter is 0x24ce2a20

0000004 FOLDBLOCKENDLEVEL(0x24fa86d0, -1, 1, [SFBINCLUDEDISABLED]) at synedithighlighterfoldbase.pas:1843
Self (the highlighter) is 0x24fa86d0

So it is accessing the wrong HL there.
I found a possible cause for this to happen. I attach a patch for it, as I can not test it. Please test with the patch, and report back.

The patch is just wrapping into Inc/DecPaintlock. The rest is indentation only.

Martin Friebe

2019-08-14 17:05

manager  

syn_hl_ranges.diff (2,080 bytes)
diff --git "a/ide/sourcesyneditor.pas" "b/ide/sourcesyneditor.pas"
index 886b05fb9a..a3fca89b63 100644
--- "a/ide/sourcesyneditor.pas"
+++ "b/ide/sourcesyneditor.pas"
@@ -1708,29 +1708,34 @@ begin
     exit
   end;
 
-  FMarkupIfDef.Highlighter := nil;
+  IncPaintLock;
+  try
+    FMarkupIfDef.Highlighter := nil;
 
-  inherited SetHighlighter(Value);
+    inherited SetHighlighter(Value);
 
-//TSynEditMarkupFoldColors(MarkupByClass[TSynEditMarkupFoldColors]).Highlighter := Highlighter; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-  if Highlighter is TSynPasSyn then
-    FMarkupIfDef.Highlighter := TSynPasSyn(Highlighter)
-  else
-    FMarkupIfDef.Highlighter := nil;
+    //TSynEditMarkupFoldColors(MarkupByClass[TSynEditMarkupFoldColors]).Highlighter := Highlighter; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+    if Highlighter is TSynPasSyn then
+      FMarkupIfDef.Highlighter := TSynPasSyn(Highlighter)
+    else
+      FMarkupIfDef.Highlighter := nil;
 
-  if Highlighter is TSynCustomFoldHighlighter then
-    FTopInfoNestList.Highlighter := TSynCustomFoldHighlighter(Highlighter)
-  else
-    FTopInfoNestList.Highlighter := nil;
+    if Highlighter is TSynCustomFoldHighlighter then
+      FTopInfoNestList.Highlighter := TSynCustomFoldHighlighter(Highlighter)
+    else
+      FTopInfoNestList.Highlighter := nil;
 
-  if FUserWordsList = nil then
-    exit;
-  if Highlighter <> nil then
-    for i := 0 to FUserWordsList.Count - 1 do
-      HighlightUserWords[i].WordBreakChars := Highlighter.WordBreakChars + TSynWhiteChars
-  else
-    for i := 0 to FUserWordsList.Count - 1 do
-      HighlightUserWords[i].ResetWordBreaks;
+    if FUserWordsList = nil then
+      exit;
+    if Highlighter <> nil then
+      for i := 0 to FUserWordsList.Count - 1 do
+        HighlightUserWords[i].WordBreakChars := Highlighter.WordBreakChars + TSynWhiteChars
+    else
+      for i := 0 to FUserWordsList.Count - 1 do
+        HighlightUserWords[i].ResetWordBreaks;
+  finally
+    DecPaintLock;
+  end;
 end;
 
 constructor TIDESynEditor.Create(AOwner: TComponent);
syn_hl_ranges.diff (2,080 bytes)

Ondrej Pokorny

2019-08-15 11:34

reporter   ~0117683

Thanks Martin for taking a look at the issue. Yes, your patch helped - I don't get the assertion failure any more!

Martin Friebe

2019-08-15 19:24

manager   ~0117690

Please close if ok

Ondrej Pokorny

2019-08-16 12:48

reporter   ~0117699

Works well - thank you very much!

Issue History

Date Modified Username Field Change
2019-08-12 16:13 Ondrej Pokorny New Issue
2019-08-12 16:13 Ondrej Pokorny File Added: Exception.png
2019-08-12 16:18 Ondrej Pokorny File Added: CurrentRanges.Assert.StackTrace.txt
2019-08-12 16:18 Ondrej Pokorny Note Added: 0117653
2019-08-12 16:28 Ondrej Pokorny File Added: synhighlighterpas-01.patch
2019-08-12 16:28 Ondrej Pokorny Note Added: 0117654
2019-08-13 21:38 Martin Friebe Assigned To => Martin Friebe
2019-08-13 21:38 Martin Friebe Status new => assigned
2019-08-14 17:05 Martin Friebe Status assigned => feedback
2019-08-14 17:05 Martin Friebe LazTarget => -
2019-08-14 17:05 Martin Friebe Note Added: 0117671
2019-08-14 17:05 Martin Friebe File Added: syn_hl_ranges.diff
2019-08-15 11:34 Ondrej Pokorny Note Added: 0117683
2019-08-15 11:34 Ondrej Pokorny Status feedback => assigned
2019-08-15 19:24 Martin Friebe Status assigned => resolved
2019-08-15 19:24 Martin Friebe Resolution open => fixed
2019-08-15 19:24 Martin Friebe Fixed in Version => 2.0.6
2019-08-15 19:24 Martin Friebe Fixed in Revision => 61697
2019-08-15 19:24 Martin Friebe LazTarget - => 2.0.6
2019-08-15 19:24 Martin Friebe Note Added: 0117690
2019-08-16 12:48 Ondrej Pokorny Status resolved => closed
2019-08-16 12:48 Ondrej Pokorny Note Added: 0117699