View Issue Details

IDProjectCategoryView StatusLast Update
0025844LazarusLCLpublic2014-03-17 00:39
ReporterMarco Dedo Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformWindowsOSWindows XP/Seven 
Target Version1.2.2 
Summary0025844: [regression] Sigsegv exception raised when assigning images to Tlistview columns
DescriptionWhen i try to assign images to Tlistview columns (viewstyle=vsreport), sigsegv exception is raised if the view is empty, or corrupted control is displayed if there is at least one Tlistitem.
This problem was not present in version 1.014.
Steps To Reproduce1) Create a new TlistView in a form, and set viewstyle=vsreport
2) Create a new TimageList containing an image
3) Assign the TimageList to TlistView "SmallImages" property.
4) Create a new column for the listview
5) Set the Column "ImageIndex" property to a 0 value (first image of TimageList) or any value different from -1.
Additional InformationAccess violation is raised trying to modify imageindex value using the IDE, SIGSEGV exception when changing the same value using a piece of code (see attached images)
TagsNo tags attached.
Fixed in Revisionr44454
LazTarget1.2.2
WidgetsetWin32/Win64
Attached Files

Relationships

related to 0025149 closedZeljan Rikalo TListView missing OwnerDraw property 
has duplicate 0025849 closedJuha Manninen IDE crashes when TListView column ImageIndex changes 

Activities

Marco Dedo

2014-03-09 21:38

reporter  

Access_Violation.PNG (39,222 bytes)   
Access_Violation.PNG (39,222 bytes)   

Marco Dedo

2014-03-09 21:39

reporter  

SIGSEGV.PNG (13,908 bytes)   
SIGSEGV.PNG (13,908 bytes)   

Marco Dedo

2014-03-09 21:39

reporter  

SIGSEGV_2.PNG (17,877 bytes)   
SIGSEGV_2.PNG (17,877 bytes)   

Marco Dedo

2014-03-09 21:40

reporter  

Wrong_Display.PNG (3,182 bytes)   
Wrong_Display.PNG (3,182 bytes)   

Zeljan Rikalo

2014-03-10 09:27

developer   ~0073580

hm...just tested with trunk lazarus 1.3 r44392 fpc-2.6.4 and there's no crashes.
Qt works ok, Gtk2 doesn't show icon in column 0 but doesn't crash, win32 (under wine) works fine. Maybe 1.2 only bug but I doubt about it since there's no changes in customlistview.inc which can produce that (could be win32ws changes which wasn't merged to 1.2 from trunk).

Maxim Ganetsky

2014-03-10 12:26

developer   ~0073594

Cannot reproduce too in Lazarus 1.2.1 r44380 FPC 2.6.3 i386-win32 on Windows XP SP3 32 bit. Lazarus 1.2.1 does not have differences from Lazarus 1.2.0 in this regard.

Do you have 32 bit or 64 bit Lazarus? Please attach project which crashes for you.

Marco Dedo

2014-03-10 18:19

reporter   ~0073611

I created a simple test program to show the issue. Compiled using 1.014 release on Windows XP 32 bit, and worked fine (a small arrow image on first column is displayed when the button is clicked).
Upgraded on the same machine to Lazarus 1.2.0, recompiled the program, it crashes with the errors shown in the images i attached yesterday (line 378 customlistview.inc).

Marco Dedo

2014-03-10 18:20

reporter  

Test.zip (129,060 bytes)

Maxim Ganetsky

2014-03-10 18:50

developer   ~0073612

Thanks, confirmed.

Zeljan Rikalo

2014-03-11 13:20

developer   ~0073628

@Maxim, win32 only issue ? Or howto reproduce on linux widgetsets ?

Maxim Ganetsky

2014-03-11 21:12

developer   ~0073638

@Zeljan
I don't know. It fails on Windows for me when I open attached test project and do step 5 from steps to reproduce.

Zeljan Rikalo

2014-03-12 07:40

developer   ~0073643

hm...don't have any windows atm, but under wine it does not crash.

Marco Dedo

2014-03-12 19:31

reporter   ~0073650

Last edited: 2014-03-12 21:27

View 2 revisions

@Zeljan
I installed Lazarus 1.2.0 32 bit for windows under Wine on a Virtualbox Opensuse Linux. I confirm that my test program works fine, but the .exe compiled under Wine crashes on a real Windows XP machine. It doesn't crash (but doesn't work, no image is shown) on Windows Seven. I guess that Wine is not very reliable for a real test of windows executables...

ocean

2014-03-13 08:11

reporter   ~0073660

Looks to me it receives CN_DRAWITEM when it shouldn't. OwnerDraw is also false

wp

2014-03-13 09:51

developer   ~0073664

When the crash occurs in "TCustomListView.DrawItem" AItem is nil. Therefore, "FCanvas.TextOut(ARect.Left + 2, ARect.Top, AItem.Caption)" must fail. But adding a check against "Assigned(AItem)" before this line does not resolve the issue since now the header of that column is not painted any more.

ocean

2014-03-13 11:24

reporter  

win32callback.inc.patch (696 bytes)   
Index: lcl/interfaces/win32/win32callback.inc
===================================================================
--- lcl/interfaces/win32/win32callback.inc	(revision 44407)
+++ lcl/interfaces/win32/win32callback.inc	(working copy)
@@ -1484,7 +1484,9 @@
           end;
         end else
         if (lWinControl <> nil) and (lWinControl is TListView) and
-          (TListView(lWinControl).ViewStyle = vsReport) then
+          (TListView(lWinControl).ViewStyle = vsReport) and
+          (PDrawItemStruct(LParam)^.ctlType = ODT_LISTVIEW) and
+          (TListView(lWinControl).OwnerDraw) then
         begin
           if PDrawItemStruct(LParam)^.itemID <> dword(-1) then
           begin
win32callback.inc.patch (696 bytes)   

ocean

2014-03-13 11:28

reporter   ~0073665

attached proposed patch

wp

2014-03-13 13:01

developer   ~0073667

Patch works fine for me. Interestingly it is applied at the a location in win32callback.inc which was modified in rev. 43156 for introduction of ListView OwnerDraw after releasing Laz 1.0.14.

Juha Manninen

2014-03-17 00:09

developer   ~0073755

Last edited: 2014-03-17 00:37

View 2 revisions

wp, it was r43157 which solved issue 0025149. I added it here as related issue.
The patch looks good. Applied, thanks.

Issue History

Date Modified Username Field Change
2014-03-09 21:38 Marco Dedo New Issue
2014-03-09 21:38 Marco Dedo File Added: Access_Violation.PNG
2014-03-09 21:39 Marco Dedo File Added: SIGSEGV.PNG
2014-03-09 21:39 Marco Dedo File Added: SIGSEGV_2.PNG
2014-03-09 21:40 Marco Dedo File Added: Wrong_Display.PNG
2014-03-10 09:27 Zeljan Rikalo Note Added: 0073580
2014-03-10 12:26 Maxim Ganetsky LazTarget => -
2014-03-10 12:26 Maxim Ganetsky Note Added: 0073594
2014-03-10 12:26 Maxim Ganetsky Status new => feedback
2014-03-10 18:19 Marco Dedo Note Added: 0073611
2014-03-10 18:19 Marco Dedo Status feedback => new
2014-03-10 18:20 Marco Dedo File Added: Test.zip
2014-03-10 18:50 Maxim Ganetsky Note Added: 0073612
2014-03-10 18:50 Maxim Ganetsky Assigned To => Maxim Ganetsky
2014-03-10 18:50 Maxim Ganetsky Status new => confirmed
2014-03-10 18:51 Maxim Ganetsky LazTarget - => 1.2.2
2014-03-10 18:51 Maxim Ganetsky Target Version => 1.2.2
2014-03-10 18:51 Maxim Ganetsky Summary Sigsegv exception raised when assigning images to Tlistview columns => [regression] Sigsegv exception raised when assigning images to Tlistview columns
2014-03-10 18:51 Maxim Ganetsky Assigned To Maxim Ganetsky =>
2014-03-11 13:20 Zeljan Rikalo Note Added: 0073628
2014-03-11 17:29 Juha Manninen Relationship added related to 0025849
2014-03-11 21:12 Maxim Ganetsky Note Added: 0073638
2014-03-12 07:40 Zeljan Rikalo Note Added: 0073643
2014-03-12 19:31 Marco Dedo Note Added: 0073650
2014-03-12 21:27 Marco Dedo Note Edited: 0073650 View Revisions
2014-03-13 08:11 ocean Note Added: 0073660
2014-03-13 09:51 wp Note Added: 0073664
2014-03-13 11:24 ocean File Added: win32callback.inc.patch
2014-03-13 11:28 ocean Note Added: 0073665
2014-03-13 13:01 wp Note Added: 0073667
2014-03-17 00:08 Juha Manninen Relationship added related to 0025151
2014-03-17 00:09 Juha Manninen Note Added: 0073755
2014-03-17 00:11 Juha Manninen Relationship replaced has duplicate 0025849
2014-03-17 00:34 Juha Manninen Relationship deleted related to 0025151
2014-03-17 00:34 Juha Manninen Relationship added related to 0025149
2014-03-17 00:37 Juha Manninen Note Edited: 0073755 View Revisions
2014-03-17 00:39 Juha Manninen Fixed in Revision => r44454
2014-03-17 00:39 Juha Manninen Status confirmed => resolved
2014-03-17 00:39 Juha Manninen Resolution open => fixed
2014-03-17 00:39 Juha Manninen Assigned To => Juha Manninen