Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 357026 - Virtual Table throws exception when AVG is installed
Summary: Virtual Table throws exception when AVG is installed
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.2   Edit
Hardware: PC Windows 7
: P3 major with 1 vote (vote)
Target Milestone: 3.8 M3   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-07 20:40 EDT by Mark McLaren CLA
Modified: 2011-10-21 16:10 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark McLaren CLA 2011-09-07 20:40:27 EDT
Build Identifier: 3.7.0 (I20110613-1736)

AVG is a popular free anti-virus program, but their latest version seems to cause SWT virtual tables to crash.

Reproducible: Always

Steps to Reproduce:
1. Download and install the free version of AVG here:
http://free.avg.com/au-en/free-antivirus-download

2. Run the snippet shown below.

3. When the table appears, scroll up and down for about 15 seconds.  Eventually the following exception is thrown:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
	at org.eclipse.swt.widgets.Table.wmNotifyChild(Table.java:6743)
	at org.eclipse.swt.widgets.Control.wmNotify(Control.java:5534)
	at org.eclipse.swt.widgets.Composite.wmNotify(Composite.java:1896)
	at org.eclipse.swt.widgets.Control.WM_NOTIFY(Control.java:5086)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4584)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1610)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2061)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4985)
	at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2424)
	at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:564)
	at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:430)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4623)
	at org.eclipse.swt.widgets.Table.windowProc(Table.java:5893)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4985)
	at org.eclipse.swt.internal.win32.OS.PeekMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.PeekMessage(OS.java:3095)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3749)
	at TestVirtualTable.main(TestVirtualTable.java:64)



------------------- code snippet -------------------------

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;


/**
 * A version of Snippet 144 with columns added. 
 */
public class TestVirtualTable {
	
	static final int COUNT = 200;
	
	public static void main(String[] args) {
		
		Display display = new Display ();
		final Shell shell = new Shell (display);
		shell.setLayout (new RowLayout (SWT.VERTICAL));
		final Table table = new Table (shell, SWT.VIRTUAL | SWT.BORDER);
		table.addListener (SWT.SetData, new Listener () {
			public void handleEvent (Event event) {
				if(event.index < 0) {
					throw new RuntimeException("Index < 0");
				}
				
				TableItem item = (TableItem) event.item;
				int index = table.indexOf (item);

				String randomString = ("" + Math.random()).substring(2, 4);
				item.setText(0, randomString);
				item.setText (1, "Foo bah do");
				item.setText(2, "Item " + index);
			}
		});
		table.setLayoutData (new RowData (200, 200));
		createColumns(table);
		
		Button button = new Button (shell, SWT.PUSH);
		button.setText ("Add Items");
		button.addListener (SWT.Selection, new Listener () {
			public void handleEvent (Event event) {

				table.clearAll();
				table.setItemCount (COUNT + 2);				
				shell.layout ();
			}
		});

		table.setItemCount (COUNT);		
		
		shell.pack ();
		shell.open ();
		while (!shell.isDisposed ()) {
			if (!display.readAndDispatch ()) display.sleep ();
		}
		display.dispose ();
	}
	
	private static void createColumns(Table tbl) {
		String[] titles = {" ", "Name", "Size"};
		for (int i = 0; i < titles.length; i++) {
			TableColumn column = new TableColumn (tbl, SWT.VIRTUAL);
			column.setText(titles [i]);
			column.setWidth(50);
		}
	}
}
Comment 1 Felipe Heidrich CLA 2011-09-08 11:39:59 EDT
Does it happen if AVG is not installed ?
Comment 2 Mark McLaren CLA 2011-09-09 12:38:54 EDT
No - as far as I can tell this bug only occurs when AVG is installed.  

Also note that disabling the 'Identity Theft Protection' feature of AVG will stop the exception from being thrown.
Comment 3 Marko Mising name CLA 2011-09-19 08:25:49 EDT
The same probleme here... Two my customers have reported problems after installing AVG Free Edition...
Comment 4 Mark McLaren CLA 2011-09-19 09:03:11 EDT
I resolved this problem by copying the Table class and editing the wmNotifyChild method to check that plvfi.iSubItem is not greater than the number of table columns:

ie. 
original:

					String[] strings = item.strings;
					if (strings != null)
						string = strings[plvfi.iSubItem];

my version:
					String[] strings = item.strings;
					if (strings != null && plvfi.iSubItem < strings.length)
						string = strings[plvfi.iSubItem];
Comment 5 Larry Colson CLA 2011-09-27 12:53:47 EDT
We just started getting calls on this exact issue.  Thanks for the fix.  Two questions:

- Is this something that will be included in a future build of swt?  

- Is this something that the eclipse organization can report to AVG?  If it's modifying parameters from the windows messages and screwing them up, who knows what other kind of wacky damage they are causing.  Seems that a report from Eclipse about this might carry far more weight than anything I could do, but we'll try anyway.

Larry Colson
Auto/Mate, Inc.
Comment 6 Felipe Heidrich CLA 2011-09-27 16:59:38 EDT
(In reply to comment #5)
> We just started getting calls on this exact issue.  Thanks for the fix.  Two
> questions:
> - Is this something that will be included in a future build of swt?  

I don't mind adding the check to the SWT code base. That said, if would be good to know why AVG is doing to cause this. Please, report a bug against them.
Comment 7 Larry Colson CLA 2011-09-27 17:06:02 EDT
Agreed.  It was submitted it to them earlier today and linked them to this bug report.   I'll post what I find out.
LC
Comment 8 Felipe Heidrich CLA 2011-09-28 11:57:20 EDT
Fixed in HEAD
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=448b28b4464a4c39dc1bd29fd464e5ceb34098ef

Please, keep us post if you learn anything from the AVG problem report. Thank you.