View Issue Details

IDProjectCategoryView StatusLast Update
0016382LazarusLCLpublic2012-02-16 09:41
ReporterEric HeijnenAssigned ToPaul Ishenin 
PrioritynormalSeverityminorReproducibilitysometimes
Status resolvedResolutionfixed 
Product Version0.9.29 (SVN)Product Build 
Target VersionFixed in Version0.9.31 (SVN) 
Summary0016382: Listview OnCustomDrawItem causes Stack overflow on vista 64-bit when themes are used
DescriptionWhen assigning an OnCustomDrawItem event to a Listview it causes a stack overflow when themes are being used


This only seems to occur on my vista 64-bit system (updated with the latest patches), it works fine in windows 7 64-bit and xp 32-bit
When themes are disabled it will run fine

I've attached a version that will crash on 'my' vista 64 system.

Additional InformationSVN 23661
TagsNo tags attached.
Fixed in Revision35392
LazTarget0.99.0
WidgetsetWin32/Win64
Attached Files
  • ownerdrawitem.zip (3,009 bytes)
  • vista.patch (702 bytes)
    Index: interfaces/win32/win32wscustomlistview.inc
    ===================================================================
    --- interfaces/win32/win32wscustomlistview.inc	(revision 26962)
    +++ interfaces/win32/win32wscustomlistview.inc	(working copy)
    @@ -209,8 +209,11 @@
     
         if not (cdrSkipDefault in DrawResult) then
         begin
    -      DrawInfo^.clrText := ColorToRGB(ALV.Canvas.Font.Color);
    -      DrawInfo^.clrTextBk := ColorToRGB(ALV.Canvas.Brush.Color);
    +      if WindowsVersion<>wvVista then
    +      begin
    +        DrawInfo^.clrText := ColorToRGB(ALV.Canvas.Font.Color);
    +        DrawInfo^.clrTextBk := ColorToRGB(ALV.Canvas.Brush.Color);
    +      end;
         end;
         ALV.Canvas.Handle := OldDC;
     
    
    vista.patch (702 bytes)
  • ListCtrlColor.zip (54,793 bytes)

Activities

2010-05-01 04:53

 

ownerdrawitem.zip (3,009 bytes)

Eric Heijnen

2010-05-01 04:57

reporter   ~0037134

also with rev.25075 build from within that vista64 system

Eric Heijnen

2010-07-30 22:40

reporter   ~0039840

Last edited: 2010-07-30 22:46

The severity of this bug should be increased to major
I've now tested it on 4 different vista 64 systems and all cause a crash on this example project (win 7 works fine, but it's a shame to tell people to upgrade to win7 if they use vista)

(and i noticed I called it a treeview again, should be listview)

Dmitry Boyarintsev

2010-08-01 13:07

developer   ~0039864

Eric, could you test the following patch (vista.patch):

Index: interfaces/win32/win32wscustomlistview.inc
===================================================================
--- interfaces/win32/win32wscustomlistview.inc (revision 26962)
+++ interfaces/win32/win32wscustomlistview.inc (working copy)
@@ -209,8 +209,11 @@
 
     if not (cdrSkipDefault in DrawResult) then
     begin
- DrawInfo^.clrText := ColorToRGB(ALV.Canvas.Font.Color);
- DrawInfo^.clrTextBk := ColorToRGB(ALV.Canvas.Brush.Color);
+ if WindowsVersion<>wvVista then
+ begin
+ DrawInfo^.clrText := ColorToRGB(ALV.Canvas.Font.Color);
+ DrawInfo^.clrTextBk := ColorToRGB(ALV.Canvas.Brush.Color);
+ end;
     end;
     ALV.Canvas.Handle := OldDC;

2010-08-01 13:09

 

vista.patch (702 bytes)
Index: interfaces/win32/win32wscustomlistview.inc
===================================================================
--- interfaces/win32/win32wscustomlistview.inc	(revision 26962)
+++ interfaces/win32/win32wscustomlistview.inc	(working copy)
@@ -209,8 +209,11 @@
 
     if not (cdrSkipDefault in DrawResult) then
     begin
-      DrawInfo^.clrText := ColorToRGB(ALV.Canvas.Font.Color);
-      DrawInfo^.clrTextBk := ColorToRGB(ALV.Canvas.Brush.Color);
+      if WindowsVersion<>wvVista then
+      begin
+        DrawInfo^.clrText := ColorToRGB(ALV.Canvas.Font.Color);
+        DrawInfo^.clrTextBk := ColorToRGB(ALV.Canvas.Brush.Color);
+      end;
     end;
     ALV.Canvas.Handle := OldDC;
 
vista.patch (702 bytes)

Eric Heijnen

2010-08-01 21:46

reporter   ~0039869

Thanks, this fixes it
As expected, the text does not have any color, but it's usable now

Dmitry Boyarintsev

2010-08-01 22:05

developer   ~0039870

It feels like DrawInfo structure is misaligned for themed Windows Vista 64 (MS bug?)
I've not found any prove of this on the Internet however.

Eric Heijnen

2010-08-02 23:47

reporter   ~0039903

Last edited: 2010-08-02 23:58

this is the buildup of the DrawInfo structure in vista 64:
EE 02 29 00 00 00 00 00 = hwndFrom
D0 48 8A 05 00 00 00 00 = idFrom
F4 FF FF FF = code = fffffff4 = -12 = NM_CUSTOMDRAW
00 00 00 00 = fill

01 00 00 00 = dwDrawStage = 1 = CDDS_PREPAINT
00 00 00 00 = fill

1F 0B 01 59 00 00 00 00 = HDC
00 00 00 00 ,18 00 00 00 ,C1 00 00 00 ,F7 00 00 00 = rect 0,24,192,247

50 3F 8C 05 00 00 00 00 = itemspec

01 00 00 00 = itemstate = CDIS_SELECTED
00 00 00 00 = fill

00 00 00 00 00 00 00 00 = application defined data
71 9C C6 7D = clrText (looks wrong)
C4 31 00 00 = clrTextBk (perhaps, but would be a weird color)

F4 00 00 00 00 00 00 00

EE 02 29 00 00 00 00 00
0F 00 00 00 00 00 00 00

I've been looking around, but I really can't figure out what goes wrong here. It just looks like the NMLVCUSTOMDRAW structure only contains the nmcd field and then continues with the next object. Not appending any of the listview data

Dmitry Boyarintsev

2010-08-03 00:20

developer   ~0039908

Last edited: 2010-08-03 00:21

What are values on Win 7 -64 bit?
(with themes enabled and theme manifest used) (please don't send 32-bit OS values)

Also, if you have time, please look for similar bug reports on the Internet, not Lazarus related.

Maybe you can also find MS VC/C++ (no C#) example of NMLVCUSTOMDRAW usage.

2010-08-03 03:23

 

ListCtrlColor.zip (54,793 bytes)

Eric Heijnen

2010-08-03 03:23

reporter   ~0039912

Last edited: 2010-08-03 03:41

for windows 7 (64-bit) the struct contains:
D2 06 04 00 00 00 00 00 = hwndFrom
10 F7 1F 05 00 00 00 00 = idFrom
F4 FF FF FF = code = fffffff4 = -12 = NM_CUSTOMDRAW
00 00 00 00 = fill
01 00 00 00 = dwDrawStage = 1 = CDDS_PREPAINT
00 00 00 00 = fill
ED 30 01 DC FF FF FF FF = HDC <
00 00 00 00 18 00 00 00 C5 00 00 00 EB 00 00 00 = rect 0,24,197, 235
00 00 00 00 00 00 00 00 = itemspec <
00 00 00 00 = itemstate
00 00 00 00 = fill
00 00 00 00 00 00 00 00 = application defined data
00 00 00 00 = clrText
00 00 00 00 = clrTextBk

00 00 00 00
02 00 00 00 = dwItemType
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

basically in win7 it's mostly 0 after the rect

http://msdn.microsoft.com/en-us/library/ms364048%28VS.80%29.aspx has a great example and compiles without trouble for x64
After compilation for 64-bit it works fine in vista

---
If you don't want to download and run that .exe on msdn.microsoft.com and then add the x64 build state, I've uploaded the converted project with the manifest embedded that I use for my project (just to be sure that that's not the problem)

Might not be such a good example after all (mainly mfc/afx stuff)

Paul Ishenin

2011-03-21 03:06

manager   ~0046710

Maybe something wrong with how "absolute" works. Please replace

DrawInfo: PNMLVCustomDraw absolute NMHdr;
with
DrawInfo: PNMLVCustomDraw;

and later in the code do:
DrawInfo := PNMLVCustomDraw(NMHdr)

Eric Heijnen

2011-03-29 02:16

reporter   ~0046905

Tried it but doesn't fix the problem

Eric Heijnen

2011-05-26 19:51

reporter   ~0048620

Jut reporting that in the more recent svn revision 30288 the above bypass (adding "if WindowsVersion<>wvVista then" ) has no effect anymore. The application crashes as soon as a listview with custom with oncustomdrawitem is shown

Paul Ishenin

2012-02-16 09:41

manager   ~0056850

Please test and close if ok.

Issue History

Date Modified Username Field Change
2010-05-01 04:53 Eric Heijnen New Issue
2010-05-01 04:53 Eric Heijnen File Added: ownerdrawitem.zip
2010-05-01 04:53 Eric Heijnen Widgetset => Win32/Win64
2010-05-01 04:57 Eric Heijnen Note Added: 0037134
2010-07-30 22:40 Eric Heijnen Note Added: 0039840
2010-07-30 22:46 Eric Heijnen Note Edited: 0039840
2010-08-01 09:43 Vincent Snijders LazTarget => -
2010-08-01 09:43 Vincent Snijders Summary Treeview OnCustomDrawItem causes Stack overflow on vista 64-bit when themes are used => Listview OnCustomDrawItem causes Stack overflow on vista 64-bit when themes are used
2010-08-01 09:43 Vincent Snijders Description Updated
2010-08-01 13:07 Dmitry Boyarintsev Note Added: 0039864
2010-08-01 13:09 Dmitry Boyarintsev File Added: vista.patch
2010-08-01 13:09 Dmitry Boyarintsev Status new => feedback
2010-08-01 21:46 Eric Heijnen Note Added: 0039869
2010-08-01 22:05 Dmitry Boyarintsev Note Added: 0039870
2010-08-01 22:05 Dmitry Boyarintsev Status feedback => new
2010-08-02 23:47 Eric Heijnen Note Added: 0039903
2010-08-02 23:52 Eric Heijnen Note Edited: 0039903
2010-08-02 23:58 Eric Heijnen Note Edited: 0039903
2010-08-03 00:20 Dmitry Boyarintsev Note Added: 0039908
2010-08-03 00:21 Dmitry Boyarintsev Note Edited: 0039908
2010-08-03 03:23 Eric Heijnen File Added: ListCtrlColor.zip
2010-08-03 03:23 Eric Heijnen Note Added: 0039912
2010-08-03 03:31 Eric Heijnen Note Edited: 0039912
2010-08-03 03:41 Eric Heijnen Note Edited: 0039912
2010-10-29 13:06 Vincent Snijders LazTarget - => 1.0
2010-10-29 13:06 Vincent Snijders Status new => acknowledged
2010-10-29 13:06 Vincent Snijders Target Version => 1.0.0
2011-03-21 03:06 Paul Ishenin Note Added: 0046710
2011-03-21 03:06 Paul Ishenin Status acknowledged => feedback
2011-03-29 02:16 Eric Heijnen Note Added: 0046905
2011-04-04 05:35 Paul Ishenin LazTarget 1.0 => 0.99.0
2011-04-04 05:38 Paul Ishenin Target Version 1.0.0 => 0.99.0
2011-05-26 19:51 Eric Heijnen Note Added: 0048620
2011-10-11 07:49 Vincent Snijders Status feedback => acknowledged
2011-10-28 11:20 Vincent Snijders Status acknowledged => assigned
2011-10-28 11:20 Vincent Snijders Assigned To => Paul Ishenin
2012-02-16 09:41 Paul Ishenin Fixed in Revision => 35392
2012-02-16 09:41 Paul Ishenin Status assigned => resolved
2012-02-16 09:41 Paul Ishenin Fixed in Version => 0.9.31 (SVN)
2012-02-16 09:41 Paul Ishenin Resolution open => fixed
2012-02-16 09:41 Paul Ishenin Note Added: 0056850