code_glitch
13-05-2014, 10:46 PM
So I recently moved to unity from cinnamon on the desktop (cinnamon 2.0 keeps locking up on my hardware spec, not Llano based laptop, trinity based laptops, an older 4X series card - only my desktop) which is what causes me to look into this.
The situation is this: on certain desktop environments (IceWM, E17, fluxbox) I cannot get a window open - and everything crashes with the following output:
X Error of failed request: BadAccess (attempt to access private resource denied)
Major opcode of failed request: 2 (X_ChangeWindowAttributes)
Serial number of failed request: 24
Current serial number in output stream: 30
I initially looked into this when trying to embed a program into a lightweight debian install. I tried debugging the code but XLib wasnt throwing anything out of the ordinary (at least not compared to the material I could find). HOWEVER: This did not happen if I had metacity running, so I could run my programs on KDE, Cinnamon, Gnome (2 and 3, including Mate) and the old unity. I assumed this was down to compositing or something fun and never thought much of it. Except I'm now looking at a composited desktop through the same compiz compositor I used to run and its now crashing with no changes to the XLib code.
So, does this ring any bells for anyone?
In case I'm doing something extremely idiotic, here is the code thats getting XLib to make the window:
procedure oX11Window.CreateWindow(X, Y, BPP: Int64);
var
FeedEvent: tXEvent;
begin
dpy := XOpenDisplay(Nil);
if Dpy = Nil then
DebugWriteln('Error connecting to X Server');
WindowHeight := Y;
WindowWidth := X;
OriginalWindowHeight := Y;
OriginalWindowWidth := X;
if (BPP <= 0) or (BPP >= Attributes[2]) then
BPP := Attributes[2] //24 bit is a good default if you you dont want anything specific
else
Attributes[2] := BPP;
BitDepth := Attributes[2];
Root := DefaultRootWindow(Dpy);
Vi := glXChooseVisual(Dpy, 0, Attributes);
if Vi = Nil then
DebugWriteln('No Visual found');
cmap := XCreateColormap(Dpy, Root, Vi^.Visual, AllocNone);
Swa.ColorMap := Cmap;
Swa.Event_Mask := ExposureMask Or KeyPressMask Or KeyReleaseMask or PointerMotionMask Or ButtonPressMask Or ButtonReleaseMask or StructureNotifyMask;
Win := XCreateWindow(Dpy, Root, 0, 0, WindowWidth, WindowHeight, 0, Vi^.Depth, InputOutput, Vi^.Visual, CWColormap Or CWEventMask, @Swa);
XSelectInput(Dpy, Root, Swa.Event_mask);
XMapWindow(Dpy, Win);
XStoreName(Dpy, Win, PChar(Name));
Glc := glXCreateContext(Dpy, Vi, Nil, True);
DebugWrite('CTXT');
glXMakeCurrent(Dpy, Win, Glc);
glEnable( GL_TEXTURE_2D );
glClearColor( 0.0, 0.0, 0.0, 0.0 );
glViewport( 0, 0, WindowWidth, WindowHeight );
glClear( GL_COLOR_BUFFER_BIT );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho(0, WindowWidth, WindowHeight, 0, -16, 16);
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
KillAtom := XInternAtom(Dpy, 'WM_DELETE_WINDOW', 0);
WMDataAtom := XInternAtom(Dpy, 'WM_PROTOCOLS', False);
XSetWMProtocols(Dpy , Root, @KillAtom, 1);
//enable fullscreen mode if requested
if FullScreen = True then
begin
WMStateAtom := XInternAtom(Dpy, '_NET_WM_STATE', False);
WMFullScreenAtom := XInternAtom(Dpy, '_NET_WM_STATE_FULLSCREEN', FullScreen);
with FeedEvent do
begin
_Type := ClientMessage;
XClient.Window := Win;
XClient.Message_type := WMStateAtom;
XClient.Format := 32;
XClient.Data.L[0] := 1;
XClient.Data.L[1] := WMFullScreenAtom;
XClient.Data.L[2] := 0;
XSendEvent(Dpy, DefaultRootWindow(Dpy), False, SubStructureNotifyMask, @FeedEvent);
end;
end;
end;
Edit: The exact line that seems to be dodgy is this:
GlXMakeCurrent(Dpy, Win, Glc);
Which is strange seeing as according to the manual BadAccess being thrown is something to do with a colour map when creating the window is it not?
The situation is this: on certain desktop environments (IceWM, E17, fluxbox) I cannot get a window open - and everything crashes with the following output:
X Error of failed request: BadAccess (attempt to access private resource denied)
Major opcode of failed request: 2 (X_ChangeWindowAttributes)
Serial number of failed request: 24
Current serial number in output stream: 30
I initially looked into this when trying to embed a program into a lightweight debian install. I tried debugging the code but XLib wasnt throwing anything out of the ordinary (at least not compared to the material I could find). HOWEVER: This did not happen if I had metacity running, so I could run my programs on KDE, Cinnamon, Gnome (2 and 3, including Mate) and the old unity. I assumed this was down to compositing or something fun and never thought much of it. Except I'm now looking at a composited desktop through the same compiz compositor I used to run and its now crashing with no changes to the XLib code.
So, does this ring any bells for anyone?
In case I'm doing something extremely idiotic, here is the code thats getting XLib to make the window:
procedure oX11Window.CreateWindow(X, Y, BPP: Int64);
var
FeedEvent: tXEvent;
begin
dpy := XOpenDisplay(Nil);
if Dpy = Nil then
DebugWriteln('Error connecting to X Server');
WindowHeight := Y;
WindowWidth := X;
OriginalWindowHeight := Y;
OriginalWindowWidth := X;
if (BPP <= 0) or (BPP >= Attributes[2]) then
BPP := Attributes[2] //24 bit is a good default if you you dont want anything specific
else
Attributes[2] := BPP;
BitDepth := Attributes[2];
Root := DefaultRootWindow(Dpy);
Vi := glXChooseVisual(Dpy, 0, Attributes);
if Vi = Nil then
DebugWriteln('No Visual found');
cmap := XCreateColormap(Dpy, Root, Vi^.Visual, AllocNone);
Swa.ColorMap := Cmap;
Swa.Event_Mask := ExposureMask Or KeyPressMask Or KeyReleaseMask or PointerMotionMask Or ButtonPressMask Or ButtonReleaseMask or StructureNotifyMask;
Win := XCreateWindow(Dpy, Root, 0, 0, WindowWidth, WindowHeight, 0, Vi^.Depth, InputOutput, Vi^.Visual, CWColormap Or CWEventMask, @Swa);
XSelectInput(Dpy, Root, Swa.Event_mask);
XMapWindow(Dpy, Win);
XStoreName(Dpy, Win, PChar(Name));
Glc := glXCreateContext(Dpy, Vi, Nil, True);
DebugWrite('CTXT');
glXMakeCurrent(Dpy, Win, Glc);
glEnable( GL_TEXTURE_2D );
glClearColor( 0.0, 0.0, 0.0, 0.0 );
glViewport( 0, 0, WindowWidth, WindowHeight );
glClear( GL_COLOR_BUFFER_BIT );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho(0, WindowWidth, WindowHeight, 0, -16, 16);
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
KillAtom := XInternAtom(Dpy, 'WM_DELETE_WINDOW', 0);
WMDataAtom := XInternAtom(Dpy, 'WM_PROTOCOLS', False);
XSetWMProtocols(Dpy , Root, @KillAtom, 1);
//enable fullscreen mode if requested
if FullScreen = True then
begin
WMStateAtom := XInternAtom(Dpy, '_NET_WM_STATE', False);
WMFullScreenAtom := XInternAtom(Dpy, '_NET_WM_STATE_FULLSCREEN', FullScreen);
with FeedEvent do
begin
_Type := ClientMessage;
XClient.Window := Win;
XClient.Message_type := WMStateAtom;
XClient.Format := 32;
XClient.Data.L[0] := 1;
XClient.Data.L[1] := WMFullScreenAtom;
XClient.Data.L[2] := 0;
XSendEvent(Dpy, DefaultRootWindow(Dpy), False, SubStructureNotifyMask, @FeedEvent);
end;
end;
end;
Edit: The exact line that seems to be dodgy is this:
GlXMakeCurrent(Dpy, Win, Glc);
Which is strange seeing as according to the manual BadAccess being thrown is something to do with a colour map when creating the window is it not?