Bug 97300

Summary: Fatal server error: GLSL compile failure: Failed to compile VS: 0:13(43): error: `pos' undeclared
Product: xorg Reporter: Paul Wise <pabs3>
Component: Server/Acceleration/glamorAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium CC: braiamp, tjaalton
Version: 7.7 (2012.06)   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
full Xorg log of the crash
none
glamor: Add declaration of "pos" for GLSL 1.20 variant none

Description Paul Wise 2016-08-11 16:48:38 UTC
Created attachment 125709 [details]
full Xorg log of the crash

Forwarding http://bugs.debian.org/834054

I have been getting quite a few GNOME session crashes.
Usually almost nothing in the systemd journal.
Just now I saw a GLSL compile error in the Xorg log.
I am using Xorg 2:1.18.4-1 on Debian testing.
More information is available in the Debian bug above.

[297584.554] Failed to compile VS: 0:13(43): error: `pos' undeclared
0:13(14): error: operands to arithmetic operators must be numeric
0:13(13): error: operands to arithmetic operators must be numeric

[297584.554] Program source:
#define ATLAS_DIM_INV 0.000976562500000000
attribute vec2 primitive;
attribute vec2 source;
varying vec2 glyph_pos;
uniform vec2 fill_offset;
uniform vec2 fill_size_inv;
varying vec2 fill_pos;
uniform vec4 v_matrix;
void main() {
       gl_Position.xy = primitive.xy * v_matrix.xz + v_matrix.yw;
       gl_Position.zw = vec2(0.0,1.0);
       glyph_pos = source.xy * ATLAS_DIM_INV;
       fill_pos = (fill_offset + primitive.xy + pos) * fill_size_inv;
}
[297584.554] (EE) 
Fatal server error:
[297584.554] (EE) GLSL compile failure
Comment 1 Michel Dänzer 2016-08-16 10:03:19 UTC
Created attachment 125810 [details] [review]
glamor: Add declaration of "pos" for GLSL 1.20 variant

Does this patch fix the problem?
Comment 2 Paul Wise 2016-08-17 03:37:39 UTC
I don't know GLSL or Xorg well enough to answer this.

I don't have any way to trigger the crash so I can't answer your question definitively.

That said, it seems like it would fix the crash but:

Did you mean to change how gl_Position is computed?

The code from the crash makes me think that fill_pos should be based on glyph_pos instead of pos?
Comment 3 braiamp 2016-08-17 04:05:30 UTC
I do have a way to trigger the crash in XFCE, by trying to open the Screensaver settings, and since both are user Debian, it seems like the same bug. I'm trying to get some useful backtrace, but I apparently aren't able to use gdb correctly.
Comment 4 Paul Wise 2016-08-17 04:35:13 UTC
The crash is just an exit with error rather than a segfault or anything that gdb would be useful for.

The error is printed to the Xorg log file, if you are using non-root Xorg that is ~/.local/share/xorg/Xorg.1.log.old (after you log in again), otherwise one of the /var/log/Xorg.*.log* files.
Comment 5 braiamp 2016-08-17 04:37:45 UTC
If that's the case, then my output is exactly the same as reporter. Will patch xorg and report the results.
Comment 6 braiamp 2016-08-17 05:54:37 UTC
After applying the patch, I can still reproduce the issue. It exits exactly the same way.
Comment 7 Michel Dänzer 2016-08-17 06:34:18 UTC
(In reply to braiamp from comment #6)
> After applying the patch, I can still reproduce the issue. It exits exactly
> the same way.

Please attach the error output with the patch applied.
Comment 8 braiamp 2016-08-17 15:23:58 UTC
[  6431.065] Failed to compile VS: 0:13(43): error: `pos' undeclared
0:13(14): error: operands to arithmetic operators must be numeric
0:13(13): error: operands to arithmetic operators must be numeric

[  6431.072] Program source:
#define ATLAS_DIM_INV 0.000976562500000000
attribute vec2 primitive;
attribute vec2 source;
varying vec2 glyph_pos;
uniform vec2 fill_offset;
uniform vec2 fill_size_inv;
varying vec2 fill_pos;
uniform vec4 v_matrix;
void main() {
       gl_Position.xy = primitive.xy * v_matrix.xz + v_matrix.yw;
       gl_Position.zw = vec2(0.0,1.0);
       glyph_pos = source.xy * ATLAS_DIM_INV;
       fill_pos = (fill_offset + primitive.xy + pos) * fill_size_inv;
}
[  6431.072] (EE) 
Fatal server error:
[  6431.072] (EE) GLSL compile failure
[  6431.072] (EE) 
[  6431.072] (EE) 
Please consult the The X.Org Foundation support 
	 at http://wiki.x.org
 for help. 
[  6431.072] (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
[  6431.072] (EE) 
[  6431.077] (II) AIGLX: Suspending AIGLX clients for VT switch
[  6431.108] (EE) Server terminated with error (1). Closing log file.

Exactly the same.
Comment 9 Michel Dänzer 2016-08-17 15:30:12 UTC
(In reply to braiamp from comment #8)
> Exactly the same.

That probably means there was a problem applying the patch, and it didn't take effect.
Comment 10 braiamp 2016-08-17 20:20:29 UTC
Yes, my mistake. It fixed my problem. Not sure if it's OP problem through. Do I have to report my own bug?
Comment 11 Michel Dänzer 2016-08-18 00:44:43 UTC
(In reply to braiamp from comment #10)
> Yes, my mistake. It fixed my problem. Not sure if it's OP problem through.
> Do I have to report my own bug?

No, it's the same problem. Thanks for testing the fix, I submitted it for review: https://patchwork.freedesktop.org/patch/105827/
Comment 12 Michel Dänzer 2016-08-23 08:08:39 UTC
commit be334f42a198a25e817e6dab43dd0e30aa1cd4f8
Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Thu Aug 18 09:40:34 2016 +0900

    glamor: Declare "pos" in the composite glyph GLSL 1.20 vertex shader

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.