Bug 9272 - glXDestroyContext causes fatal error when sharing display lists (dri)
Summary: glXDestroyContext causes fatal error when sharing display lists (dri)
Status: RESOLVED MOVED
Alias: None
Product: Mesa
Classification: Unclassified
Component: GLX (show other bugs)
Version: 6.4
Hardware: x86 (IA32) Linux (All)
: high critical
Assignee: mesa-dev
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-06 23:30 UTC by dnakedp
Modified: 2019-09-18 17:10 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description dnakedp 2006-12-06 23:30:32 UTC
Using direct rendering create a window then create a subwindow which shares
display lists with the first window. As long as nothing is drawn into the
windows everything is fine. However, drawing anything then destroying the
windows and deleting the contexts causes the following error:

X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  143 (XFree86-DRI)
  Minor opcode of Vertex3f: 1
  Value in failed request:  0x1400004
  Serial number of failed request:  61
  Current serial number in output stream:  61

I also sometimes see this message while drawing:

Vertex3f: 1

If only one context (either) is deleted everything is fine. I'm using the r200
dri driver.

Here is a short example I put together to test this outside of my real app as
perhaps I'm doing something wrong:

#include <stdio.h>
#include <X11/Xlib.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glx.h>

GLXContext main_gc = NULL, gc1 = NULL, gc2 = NULL;
Window win1, win2;
Display *disp;
int screen;

void Create_Window() {
   static int count = 0;
   char *nm = "Hi";
   Colormap cmap;
   int vi_attr[] = {GLX_RGBA, GLX_DOUBLEBUFFER, GLX_RED_SIZE, 1,
                    GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, None};
   unsigned long mask = 0;
   XClassHint *chint;
   XColor xclr;
   XSetWindowAttributes attr;
   XSizeHints *shint;
   XTextProperty wname;
   XVisualInfo *vi;
   XWMHints *whint;

   vi = glXChooseVisual(disp, screen, vi_attr);
   if (count) {
      if ((gc2 = glXCreateContext(disp, vi, main_gc, GL_TRUE)) == NULL) {
         puts("cannot create context");
         return;
      }
   }
   else {
      if ((gc1 = glXCreateContext(disp, vi, main_gc, GL_TRUE)) == NULL) {
         puts("cannot create context");
         return;
      }
      main_gc = gc1;
   }
   cmap = XCreateColormap(disp, RootWindow(disp, screen), vi->visual,
                          AllocNone);
   attr.colormap = cmap;
   xclr.red = 65535;
   xclr.green = 65535;
   xclr.blue = 65535;
   XAllocColor(disp, cmap, &xclr);
   attr.border_pixel = xclr.pixel;
   attr.event_mask = ExposureMask | StructureNotifyMask | ButtonPressMask;
   mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
   if (count) 
      win2 = XCreateWindow(disp, win1, 10, 10, 10, 10, 1, vi->depth,
                           InputOutput, vi->visual, mask, &attr);
   else
      win1 = XCreateWindow(disp, RootWindow(disp, screen), 10, 10, 200, 200,
                           2, vi->depth, InputOutput, vi->visual, mask, &attr);
   XStringListToTextProperty(&nm, 1, &wname);
   if ((shint = XAllocSizeHints()) != NULL) {
      shint->x = 10;
      shint->y = 10;
      shint->width = 200;
      shint->height = 200;
      shint->base_width = 200;
      shint->base_height = 200;
      shint->win_gravity = NorthWestGravity;
      shint->flags = USSize | USPosition | PWinGravity;
   }
   if ((whint = XAllocWMHints()) != NULL) {
      whint->flags = InputHint | StateHint;
      whint->input = True;
      whint->initial_state = NormalState;
   }
   if ((chint = XAllocClassHint()) != NULL) {
      chint->res_name = nm;
      chint->res_class = nm;
   }
   if (count)
      XSetWMProperties(disp, win2, &wname, &wname, NULL, 0, shint, whint,
                       chint);
   else
      XSetWMProperties(disp, win1, &wname, &wname, NULL, 0, shint, whint,
                       chint);
   XFree(wname.value);
   XFree(shint);
   XFree(whint);
   XFree(chint);
   XFree(vi);
   if (count)
      XMapWindow(disp, win2);
   else
      XMapWindow(disp, win1);
   count++;
}

int main() {
   bool alive = true;
   XEvent event;

   if ((disp = XOpenDisplay("")) == NULL) {
      puts("cannot open display");
      return(0);
   }
   screen = DefaultScreen(disp);

   Create_Window();

   while(alive) {
      XNextEvent(disp, &event);
      switch(event.type) {
      case ButtonPress:
         if (gc2)
            alive = false;
         else
            Create_Window();
         break;
      case ConfigureNotify:
         break;
      case Expose:
         if (event.xexpose.count != 0) break;
         glXMakeCurrent(disp, win1, gc1);
         glMatrixMode(GL_PROJECTION);
         glLoadIdentity();
         glViewport(0, 0, 200, 200);
         glOrtho(0, 200, 0, 200, -1, 1);
         glClearColor(0.0, 0.0, 0.0, 0.0);
         glClear(GL_COLOR_BUFFER_BIT);
         glMatrixMode(GL_MODELVIEW);
         glLoadIdentity();
         glColor3f(1.0, 1.0, 1.0);
         glBegin(GL_QUADS);
           glVertex2f(10.0, 10.0);
           glVertex2f(30.0, 10.0);
           glVertex2f(30.0, 30.0);
           glVertex2f(10.0, 30.0);
         glEnd();
         glXSwapBuffers(disp, win1);
         break;
      case MapNotify:
         break;
      default: ;
      };
   }
   XDestroyWindow(disp, win2);
   glXDestroyContext(disp, gc2);
   XDestroyWindow(disp, win1);
   glXDestroyContext(disp, gc1);
   return(0);
}
Comment 1 Kristian Høgsberg 2010-05-12 14:20:59 UTC
I can see you're running DRI1, and I believe this is fixed with DRI2.  On my intel hardware with DRI2 your test case works as expected.  The radeon drivers support DRI2 too so I recommend you give that a try and see if it fixes your problem.
Comment 2 Ian Romanick 2012-05-31 14:18:03 UTC
Does this bug still occur?
Comment 3 GitLab Migration User 2019-09-18 17:10:47 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/mesa/mesa/issues/48.


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.