View Issue Details

IDProjectCategoryView StatusLast Update
0031635PatchesLCLpublic2017-06-15 12:52
ReporterPetr-K Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilitysometimes
Status closedResolutionfixed 
PlatformWin64OSWindows 
Product Version1.5 (SVN) 
Summary0031635: Range check error in ComboBoxWindowProc
DescriptionSometimes my x64 application dies on Win7 x64.

Crashdump stack trace:
app!fpc_rangeerror+0x1e [..\inc\system.inc @ 747]
app!COMBOBOXWINDOWPROC+0x90
user32!UserCallWinProcCheckWow+0x1ad

Problematic line is:
SetWindowLong(Window, GWL_ID, PtrInt(NCCreateParams^.WinControl));

Function SetWindowLong is defined in unit windows, but last parameter is 32bit - causes sometimes range check.
The same function SetWindowLong is defined in LCLIntf with correct parameters (calls Windows.SetWindowLongPtrW)

Adding LCLIntf after Windows unit solves this issue.

Patch is included. (I must modify one line with func. GetProp - different result type in windows/lclintf)
TagsNo tags attached.
Fixed in Revisionr54600
LazTarget-
WidgetsetWin32/Win64
Attached Files

Relationships

related to 0031670 closedMichl Lazarus Caption in TGroupBox with Enabled=False 

Activities

Petr-K

2017-04-05 12:24

reporter  

win32wsstdctrls.patch (1,180 bytes)   
Index: win32wsstdctrls.pp
===================================================================
--- win32wsstdctrls.pp	(revision 49737)
+++ win32wsstdctrls.pp	(working copy)
@@ -31,7 +31,7 @@
   Classes, SysUtils, CommCtrl,
   StdCtrls, Controls, Graphics, Forms, Themes,
 ////////////////////////////////////////////////////
-  WSControls, WSStdCtrls, WSLCLClasses, WSProc, Windows, LCLType,
+  WSControls, WSStdCtrls, WSLCLClasses, WSProc, Windows, LCLIntf, LCLType,
   LazUTF8, LazUtf8Classes, InterfaceBase, LMessages, LCLMessageGlue,
   Win32Int, Win32Proc, Win32WSControls, Win32Extra, Win32Themes;
 
@@ -723,7 +723,7 @@
   Handle := ACustomListBox.Handle;
   // The check for GetProp is required because of some division error which happens
   // if call LB_GETITEMRECT on window initialization
-  Result := (GetProp(Handle, 'WinControl') <> 0) and (Windows.SendMessage(Handle, LB_GETITEMRECT, Index, LPARAM(@ARect)) <> LB_ERR);
+  Result := Assigned(GetProp(Handle, 'WinControl')) and (Windows.SendMessage(Handle, LB_GETITEMRECT, Index, LPARAM(@ARect)) <> LB_ERR);
 end;
 
 class function TWin32WSCustomListBox.GetScrollWidth(const ACustomListBox: TCustomListBox): Integer;
win32wsstdctrls.patch (1,180 bytes)   

Juha Manninen

2017-04-07 08:32

developer   ~0099434

Last edited: 2017-04-07 08:35

View 2 revisions

You apparently used a very old version of Lazarus sources. The report says "1.5 (SVN)", r49737. It is from September 2015. ???
Please use the latest trunk.
---
$ patch -p0 < ~/patch/win32wsstdctrls.patch
patching file win32wsstdctrls.pp
Hunk 0000001 FAILED at 31.
Hunk 0000002 succeeded at 803 (offset 80 lines).
1 out of 2 hunks FAILED -- saving rejects to file win32wsstdctrls.pp.rej
---

Even better if you created the patch from top level directory of Lazarus sources.
Then all file paths are included and it can also be applied from the top level directory.

Petr-K

2017-04-10 15:52

reporter  

win32wsstdctrls.patch2 (1,193 bytes)

Petr-K

2017-04-10 15:59

reporter  

win32wsstdctrls-toplevel.patch (1,256 bytes)   
Index: lcl/interfaces/win32/win32wsstdctrls.pp
===================================================================
--- lcl/interfaces/win32/win32wsstdctrls.pp	(revision 54599)
+++ lcl/interfaces/win32/win32wsstdctrls.pp	(working copy)
@@ -31,7 +31,7 @@
   Classes, SysUtils, CommCtrl,
   StdCtrls, Controls, Graphics, Forms, Themes,
 ////////////////////////////////////////////////////
-  WSControls, WSStdCtrls, WSLCLClasses, WSProc, Windows, LCLType,
+  WSControls, WSStdCtrls, WSLCLClasses, WSProc, Windows, LCLIntf, LCLType,
   LazUTF8, LazUtf8Classes, InterfaceBase, LMessages, LCLMessageGlue, TextStrings,
   Win32Int, Win32Proc, Win32WSControls, Win32Extra, Win32Themes;
 
@@ -803,7 +803,7 @@
   Handle := ACustomListBox.Handle;
   // The check for GetProp is required because of some division error which happens
   // if call LB_GETITEMRECT on window initialization
-  Result := (GetProp(Handle, 'WinControl') <> 0) and (Windows.SendMessage(Handle, LB_GETITEMRECT, Index, LPARAM(@ARect)) <> LB_ERR);
+  Result := Assigned(GetProp(Handle, 'WinControl')) and (Windows.SendMessage(Handle, LB_GETITEMRECT, Index, LPARAM(@ARect)) <> LB_ERR);
 end;
 
 class function TWin32WSCustomListBox.GetScrollWidth(const ACustomListBox: TCustomListBox): Integer;
win32wsstdctrls-toplevel.patch (1,256 bytes)   

Petr-K

2017-04-10 15:59

reporter   ~0099542

I merged it into svn rev 54599 and made win32wsstdctrls-toplevel.patch

Juha Manninen

2017-04-10 16:27

developer   ~0099543

Applied, thanks.

Issue History

Date Modified Username Field Change
2017-04-05 12:24 Petr-K New Issue
2017-04-05 12:24 Petr-K File Added: win32wsstdctrls.patch
2017-04-05 13:45 Bart Broersma Project Lazarus => Patches
2017-04-06 22:04 Juha Manninen Assigned To => Juha Manninen
2017-04-06 22:04 Juha Manninen Status new => assigned
2017-04-07 08:32 Juha Manninen LazTarget => -
2017-04-07 08:32 Juha Manninen Note Added: 0099434
2017-04-07 08:32 Juha Manninen Status assigned => feedback
2017-04-07 08:35 Juha Manninen Note Edited: 0099434 View Revisions
2017-04-10 15:52 Petr-K File Added: win32wsstdctrls.patch2
2017-04-10 15:59 Petr-K File Added: win32wsstdctrls-toplevel.patch
2017-04-10 15:59 Petr-K Note Added: 0099542
2017-04-10 15:59 Petr-K Status feedback => assigned
2017-04-10 16:27 Juha Manninen Fixed in Revision => r54600
2017-04-10 16:27 Juha Manninen Note Added: 0099543
2017-04-10 16:27 Juha Manninen Status assigned => resolved
2017-04-10 16:27 Juha Manninen Resolution open => fixed
2017-04-17 09:54 Juha Manninen Relationship added related to 0031670
2017-06-15 12:52 Petr-K Status resolved => closed