Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 487467

Summary: [GTK3] org_eclipse_swt_widgets_Text.test_getTopIndex fails
Product: [Eclipse Project] Platform Reporter: Eric Williams <ericwill>
Component: SWTAssignee: Eric Williams <ericwill>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: akurtakov, arunkumar.thondapu, daniel_megert, Lars.Vogel, lufimtse, markus.kell.r, sravankumarl
Version: 4.6Flags: akurtakov: review+
arunkumar.thondapu: review+
sravankumarl: review+
Target Milestone: 4.6 RC3   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/70980
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=49807d830c551e52f478d4ccc4d6fa3f481d1f62
https://git.eclipse.org/r/71140
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=cf344d18125866944c714112418407308ab5e2cf
https://git.eclipse.org/r/73329
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=83f68458d1ae8ca986e87c6cf49dcb5c4bf9ba65
Whiteboard:
Bug Depends on: 461354    
Bug Blocks:    

Description Eric Williams CLA 2016-02-08 13:30:26 EST
I have been seeing this test failure in AllNonBrowserTests for awhile. On GTK3.16+ it is the only test failure remaining. 

It goes back as far as GTK3.14, possibly further -- I haven't checked past GTK3.14. This does not happen on GTK2.
Comment 1 Sravan Kumar Lakkimsetti CLA 2016-02-11 01:49:20 EST
The root cause of this problem is Bug 461354. We need to develop a workaround for that problem to fix this issue.

I raised a GTK bug for this. But GTK team came bask saying that that is the expected behavior.

Please review the bug 461354 for this. This has a GTK only reproducible scenario.
Comment 2 Eric Williams CLA 2016-02-11 11:54:51 EST
(In reply to Sravan Kumar Lakkimsetti from comment #1)
> The root cause of this problem is Bug 461354. We need to develop a
> workaround for that problem to fix this issue.
> 
> I raised a GTK bug for this. But GTK team came bask saying that that is the
> expected behavior.
> 
> Please review the bug 461354 for this. This has a GTK only reproducible
> scenario.

Thanks Sravan, I was unaware of that bug. I'll add this one as a blocker.
Comment 3 Eric Williams CLA 2016-04-19 09:53:42 EDT
(In reply to Sravan Kumar Lakkimsetti from comment #1)
> The root cause of this problem is Bug 461354. We need to develop a
> workaround for that problem to fix this issue.
> 
> I raised a GTK bug for this. But GTK team came bask saying that that is the
> expected behavior.
> 
> Please review the bug 461354 for this. This has a GTK only reproducible
> scenario.

So I've made some progress on this bug (for Text at least). GtkTextView has something called a GtkTextMark, which is ideal for preserving text position as it operates similar to an "invisible cursor". More importantly it updates properly and does not delay due to line validation like a GtkTextIter does.

Basically in Text we can specify a GtkTextMark and set it to the correct index every time setTopIndex() is called. When getTopIndex() is called, we can convert that GtkTextMark into a GtkTextIter and retrieve the proper line position using gtk_text_iter_get_line().

I'll upload a patch shortly for this bug. As for bug 461354, I made some progress for List widgets but it's more of a workaround.
Comment 4 Eclipse Genie CLA 2016-04-19 12:16:25 EDT
New Gerrit change created: https://git.eclipse.org/r/70980
Comment 5 Eric Williams CLA 2016-04-21 08:47:30 EDT
*** Bug 485681 has been marked as a duplicate of this bug. ***
Comment 7 Sravan Kumar Lakkimsetti CLA 2016-04-21 08:59:25 EDT
In master now
Comment 8 Eclipse Genie CLA 2016-04-21 09:20:42 EDT
New Gerrit change created: https://git.eclipse.org/r/71140
Comment 10 Eric Williams CLA 2016-04-21 09:26:06 EDT
(In reply to Eclipse Genie from comment #9)
> Gerrit change https://git.eclipse.org/r/71140 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=cf344d18125866944c714112418407308ab5e2cf

I just noticed that I didn't have the /*int*/ tags in OS.java for 32-bit stuff. Fixed that up and merged it.
Comment 11 Eric Williams CLA 2016-05-20 15:28:13 EDT
Re-opening as there is a regression. There is a case where getTopIndex() is called without first calling setTopIndex(), and the user *has not* done any scrolling. This causes a native GTK crash.

The regression can be reproduced using Snippet243. I have a patch in the works.
Comment 12 Eclipse Genie CLA 2016-05-20 15:51:55 EDT
New Gerrit change created: https://git.eclipse.org/r/73329
Comment 13 Eric Williams CLA 2016-05-20 15:53:21 EDT
(In reply to Eclipse Genie from comment #12)
> New Gerrit change created: https://git.eclipse.org/r/73329

This patch fixes the issue.
Comment 14 Arun Thondapu CLA 2016-05-25 09:39:17 EDT
(In reply to Eric Williams from comment #13)
> (In reply to Eclipse Genie from comment #12)
> > New Gerrit change created: https://git.eclipse.org/r/73329
> 
> This patch fixes the issue.

Patch looks good, +1 from me.
Comment 15 Alexander Kurtakov CLA 2016-05-25 10:00:55 EDT
Good catch. +1 from me.
Comment 17 Sravan Kumar Lakkimsetti CLA 2016-05-25 10:13:56 EDT
Merged to master
Comment 18 Eric Williams CLA 2016-05-25 11:55:35 EDT
*** Bug 494565 has been marked as a duplicate of this bug. ***
Comment 19 Markus Keller CLA 2016-05-25 12:14:41 EDT
Bug 494565 is not a dup.

> 	long /*int*/ indexMark = 0;

In the future, please use correct variable names (topIndexMark) and avoid redundant initializations (" = 0").
Comment 20 Eric Williams CLA 2016-05-25 13:45:43 EDT
(In reply to Markus Keller from comment #19)
> and avoid redundant initializations (" = 0").

I was told to add this during the gerrit review.
Comment 21 Markus Keller CLA 2016-05-25 15:06:02 EDT
Sorry, that review comment was wrong.

Sravan, please read http://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.12.5 . There are no uninitialized variables in Java.