View Issue Details

IDProjectCategoryView StatusLast Update
0015964LazarusIDEpublic2011-12-01 11:23
ReporterAleksa TodorovicAssigned ToMartin Friebe 
PriorityurgentSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformWindowsOSXPOS Version
Product Version0.9.29 (SVN)Product Build 
Target Version0.9.30Fixed in Version0.9.29 (SVN) 
Summary0015964: Access Violation while trying to code-complete (with patch)
DescriptionI get AV when I try to code complete in my project. Unfortunately, I am not able to reproduce the problem with small project, but here is stack trace of exception.

#0 TSYNBASECOMPLETIONFORM__DOONRESIZE(0x97eb920) at syncompletion.pas:841
0000001 TCONTROL__RESIZE(0x97eb920) at .\include\control.inc:2986
0000002 TWINCONTROL__INITIALIZEWND(0x97eb920) at .\include\wincontrol.inc:7176
0000003 TCUSTOMFORM__INITIALIZEWND(0x97eb920) at .\include\customform.inc:926
0000004 TWINCONTROL__CREATEWND(0x97eb920) at .\include\wincontrol.inc:7054
0000005 TSCROLLINGWINCONTROL__CREATEWND(0x97eb920) at .\include\scrollingwincontrol.inc:32
0000006 TCUSTOMFORM__CREATEWND(0x97eb920) at .\include\customform.inc:2134
0000007 TFORM__CREATEWND(0x97eb920) at .\include\customform.inc:2535
0000008 TWINCONTROL__CREATEHANDLE(0x97eb920) at .\include\wincontrol.inc:6934
0000009 TWINCONTROL__HANDLENEEDED(0x97eb920) at .\include\wincontrol.inc:7412
0000010 TWINCONTROL__GETHANDLE(0x97eb920) at .\include\wincontrol.inc:6222
0000011 TWINCONTROL__GETDEVICECONTEXT(0, 0x97eb920) at .\include\wincontrol.inc:7821
0000012 TCONTROLCANVAS__CREATEHANDLE(0x8dbbd98) at .\include\controlcanvas.inc:90
0000013 TCANVAS__REQUIREDSTATE([CSHANDLEVALID..CSBRUSHVALID], 0x8dbbd98) at .\include\canvas.inc:1550
0000014 TCANVAS__GETHANDLE(0x8dbbd98) at .\include\canvas.inc:1450
0000015 TSYNBASECOMPLETIONFORM__FONTCHANGED(0x7918dd0, 0x97eb920) at syncompletion.pas:862
0000016 TSYNBASECOMPLETIONFORM__CREATE(0x9319118, 0xc6b968, 0x97eb920) at syncompletion.pas:426
0000017 TSYNBASECOMPLETION__CREATE(0x7452688, 0x0, 0x9319118) at syncompletion.pas:927
0000018 TSYNCOMPLETION__CREATE(0x7452688, 0xc6c36c, 0x9319118) at syncompletion.pas:1390
0000019 TSOURCENOTEBOOK__CREATECOMPLETIONFORM(0x7452688) at sourceeditor.pp:3732
0000020 TSOURCEEDITOR__STARTIDENTCOMPLETIONBOX(true, 0x787f360) at sourceeditor.pp:2806
0000021 TSOURCEEDITOR__PROCESSUSERCOMMAND(0x91a1088, 1103, '', 0x0, 0x787f360) at sourceeditor.pp:1729
0000022 TCUSTOMSYNEDIT__DOONPROCESSCOMMAND(1103, '', 0x0, 0x91a1088) at synedit.pp:6294
0000023 TCUSTOMSYNEDIT__COMMANDPROCESSOR(1103, '', 0x0, 0x91a1088) at synedit.pp:5662
0000024 TCUSTOMSYNEDIT__KEYDOWN(0, [SSCTRL], 0x91a1088) at synedit.pp:2234
0000025 TWINCONTROL__KEYDOWNBEFOREINTERFACE(0, [SSCTRL], 0x91a1088) at .\include\wincontrol.inc:5364
0000026 TWINCONTROL__DOKEYDOWNBEFOREINTERFACE({MSG = 48384, CHARCODE = 0, UNUSED = 1792, KEYDATA = 3735553, RESULT = 0}, 0x91a1088) at .\include\wincontrol.inc:5501
0000027 TWINCONTROL__CNKEYDOWN({MSG = 48384, CHARCODE = 0, UNUSED = 1792, KEYDATA = 3735553, RESULT = 0}, 0x91a1088) at .\include\wincontrol.inc:6691
0000028 SYSTEM_TOBJECT_$__DISPATCH$formal at :0
0000029 TWINCONTROL__WMSIZE({MSG = 48384, SIZETYPE = 117440512, WIDTH = 1, HEIGHT = 57, RESULT = 0}, 0x91a1088) at .\include\wincontrol.inc:6679
0000030 TWINCONTROL__WNDPROC({MSG = 48384, WPARAM = 117440512, LPARAM = 3735553, RESULT = 0, WPARAMLO = 0, WPARAMHI = 1792, LPARAMLO = 1, LPARAMHI = 57, RESULTLO = 0, RESULTHI = 0}, 0x91a1088) at .\include\wincontrol.inc:5130
0000031 TCUSTOMSYNEDIT__WNDPROC({MSG = 48384, WPARAM = 117440512, LPARAM = 3735553, RESULT = 0, WPARAMLO = 0, WPARAMHI = 1792, LPARAMLO = 1, LPARAMHI = 57, RESULTLO = 0, RESULTHI = 0}, 0x91a1088) at synedit.pp:5223
0000032 DELIVERMESSAGE(0x91a1088, void) at lclmessageglue.pas:111
0000033 WINDOWPROC(11209350, 256, 32, 3735553) at win32callback.inc:2417
TagsNo tags attached.
Fixed in Revision23948
LazTarget0.9.30
Widgetset
Attached Files
  • patch_code_completition_bug15964.patch (573 bytes)
    Index: components/synedit/syncompletion.pas
    ===================================================================
    --- components/synedit/syncompletion.pas	(revision 23944)
    +++ components/synedit/syncompletion.pas	(working copy)
    @@ -838,7 +838,7 @@
       OldHeight:=Bitmap.Height+2;
       OldWidth:=Bitmap.Width+Scroll.Width;
       if (OldHeight<>Height) or (OldWidth<>Width) then begin
    -    FNbLinesInWindow := (Height-2+(fFontHeight-1)) div fFontHeight;
    +    if (fFontHeight>0) then FNbLinesInWindow := (Height-2+(fFontHeight-1)) div fFontHeight;
         Invalidate;
       end;
     end;
    

Activities

2010-03-11 17:41

 

patch_code_completition_bug15964.patch (573 bytes)
Index: components/synedit/syncompletion.pas
===================================================================
--- components/synedit/syncompletion.pas	(revision 23944)
+++ components/synedit/syncompletion.pas	(working copy)
@@ -838,7 +838,7 @@
   OldHeight:=Bitmap.Height+2;
   OldWidth:=Bitmap.Width+Scroll.Width;
   if (OldHeight<>Height) or (OldWidth<>Width) then begin
-    FNbLinesInWindow := (Height-2+(fFontHeight-1)) div fFontHeight;
+    if (fFontHeight>0) then FNbLinesInWindow := (Height-2+(fFontHeight-1)) div fFontHeight;
     Invalidate;
   end;
 end;

Aleksa Todorovic

2010-03-11 17:42

reporter   ~0035273

Attached patch solves AV, and makes code-completion works.

Zeljan Rikalo

2010-03-11 18:40

developer   ~0035279

Changed prio to urgent and 0.9.30 - code completion does not work at all.

Zeljan Rikalo

2010-03-11 18:47

developer   ~0035280

Tested blindly with supplied patch and it works ok but have one question:
What if FFontHeight < 0 ? Shouldn't it be fixed in TSynBaseCompletionForm.FontChanged() instead of workaround here ? (asking because I'm short in synbasecompletion philosophy)

Martin Friebe

2010-03-11 20:01

manager   ~0035282

I had a look: FFontHeight should not be smaller than 0.

It normally even should not be smaller than 2. TextMetric.tmHeight should not get negative.

The problem only happens during creation, where FFontHeight is accessed, before it is first set.

FontChanged will set it; but FontChanged needs the handle, which cause resize, which reads FFontHeight before it is set (and therefore gets 0.

I think the patch is ok, it protects DoOnResize from crashing, while the form is in creation.

Zeljan Rikalo

2010-03-11 20:25

developer   ~0035286

So why don't you commit then ? :)

Martin Friebe

2010-03-11 20:36

manager   ~0035288

Done

Issue History

Date Modified Username Field Change
2010-03-11 17:40 Aleksa Todorovic New Issue
2010-03-11 17:41 Aleksa Todorovic File Added: patch_code_completition_bug15964.patch
2010-03-11 17:42 Aleksa Todorovic Note Added: 0035273
2010-03-11 18:40 Zeljan Rikalo LazTarget => 0.9.30
2010-03-11 18:40 Zeljan Rikalo Note Added: 0035279
2010-03-11 18:40 Zeljan Rikalo Priority normal => urgent
2010-03-11 18:47 Zeljan Rikalo Note Added: 0035280
2010-03-11 18:47 Zeljan Rikalo Status new => feedback
2010-03-11 20:01 Martin Friebe Note Added: 0035282
2010-03-11 20:11 Martin Friebe Status feedback => assigned
2010-03-11 20:11 Martin Friebe Assigned To => Martin Friebe
2010-03-11 20:25 Zeljan Rikalo Note Added: 0035286
2010-03-11 20:36 Martin Friebe Fixed in Revision => 23948
2010-03-11 20:36 Martin Friebe Status assigned => resolved
2010-03-11 20:36 Martin Friebe Fixed in Version => 0.9.29 (SVN)
2010-03-11 20:36 Martin Friebe Resolution open => fixed
2010-03-11 20:36 Martin Friebe Note Added: 0035288
2010-03-11 20:37 Martin Friebe Target Version => 0.9.30
2011-12-01 11:23 Marc Weustink Status resolved => closed