DGA Problems (segfault when exiting)

DGA Problems (segfault when exiting)

Post by Jeff Week » Wed, 29 Oct 1997 04:00:00



I've written a little DGA driver for my portable graphics library and it
seems to work fine, except that every time I exit a program that uses
it, I get a segfault:

Using DGA version 1.0
video memory unprotecting
MemBase = 0x401a9000, Width = 1024, BankSize = 2097152
Running at 1024x768x16
video memory protecting
Segmentation fault

If anybody can tell me how I can get rid of this, I'd be very grateful.
For completeness I will include a few relavent functions.  You'll notice
I don't support banking yet... that's simply because I haven't gotten to
that stage.  My card doesn't require banking, so it's currently not a
problem.

int detect(void) {
  int major, minor, event_base, error_base;

  // Try to connect to the X Server
  display = XOpenDisplay(NULL);
  if( display == NULL ) return 1;

  if(!XF86DGAQueryVersion(display,&major,&minor)) {
    printf("DGA version query failed\n");
    return 1;
  }

  if(!XF86DGAQueryExtension(display,&event_base,&error_base)) {
    printf("DGA extension query failed\n");
    return 1;
  }

  // Fail if the extension version in the server is too old
  if(major < 1 || (major == 1 && minor < 0)) {
    printf("DGA extension is too old, get version 1.0 or higher\n");
    return 1;
  }
  else printf("Using DGA version %d.%d", major, minor);

  // Flag that we're using the MIT-SHM driver
  petal.magic = DGA;
  return 0;

Quote:}

int set_mode(char *window_name, int x, int y, int bpp) {
  XSetWindowAttributes xswa;
  int ram, mem_size;
  unsigned long mask;
  int width, height;

  XF86DGAGetViewPortSize(display, DefaultScreen(display), &width,
&height);
  screen = DefaultScreenOfDisplay(display);
  gc = XDefaultGC(display,DefaultScreen(display));

  // override redirect tells the window manger to just ignore us
  xswa.override_redirect = True;
  xswa.event_mask = ButtonPressMask | ButtonReleaseMask |
ButtonMotionMask |
                    StructureNotifyMask | KeyPressMask | KeyReleaseMask;
  xswa.background_pixel = BlackPixelOfScreen(screen);
  mask = CWEventMask | CWOverrideRedirect | CWBackPixel;

  // Create the window
  printf("Creating window\n");
  window = XCreateWindow(display, DefaultRootWindow(display), 0, 0,
                         width, height, 0, CopyFromParent, InputOutput,
                         CopyFromParent, mask, &xswa);

  // Setup some properties
  // XSetStandardProperties(display, window, window_name, window_name,
None, NULL, 0, NULL);

  if(!window) {
    printf("Unable to open window.\n");
    return 1;
  }

  XMapWindow(display,window);
  XRaiseWindow(display,window);

  XF86DGAGetVideo(display, DefaultScreen(display), &address,
&bytes_per_line, &bank_size, &ram);
  XF86DGADirectVideo(display, DefaultScreen(display),
                     XF86DGADirectGraphics /*| XF86DGADirectMouse |
XF86DGADirectKeyb*/);

  printf("MemBase = 0x%x, Width = %i, BankSize = %i\n", address,
bytes_per_line, bank_size);

  if(bank_size < (ram * 1024)) {
    printf("Banked memory... ");
    XF86DGASetVidPage(display,DefaultScreen(display),0);
  }

  printf("Setting viewport\n");
  XF86DGASetViewPort(display,DefaultScreen(display),0,0);

  // Setup some info about the mode we're in
  petal.max_x = width;
  petal.max_y = height;
  petal.bpp = DefaultDepthOfScreen(screen);
  if(petal.bpp == 15) petal.size = (width * height) << 1;
  else petal.size = width * height * (petal.bpp >> 3);

  return 0;

Quote:}

void deinit(void) {
  // give control back to the X server
  XF86DGADirectVideo(display,DefaultScreen(display),0);
  // and delete our window, etc.
  XFreeGC(display, gc);
  XDestroyWindow(display, window);
  XCloseDisplay(display);

Quote:}

Thanks again,
Jeff

PS: Please reply via email where possible.

--------------------------------------------
            - Code X Software -
       Programming to a Higher Power


  web:   http://www.execulink.com/~pweeks/
--------------------------------------------

 
 
 

1. X server crashes when exiting DGA app (xmame.x11)

Hi All,

I was wondering if anyone else has experienced this problem. Basically,
whenever I use xmame.x11 in DGA mode, the X Server crashes when I exit
the app.

I have an ASUS GeForce2 GTS card (nvidia chipset), but at the moment I do
not have their 3D-accelerated drivers installed (due to a different
unrelated problem).

I can reproduce the crash at will, if anyone wants to see the logs.

Strangely enough, mplayer does not seem to exhibit this problem in DGA
mode.
--
Cynic, n.:
        Experienced.

2. loop.c warning removal

3. su segfault on exit.

4. Help

5. Segfaulting when exiting X on OpenBSD/Sparc

6. PCI NE2000 clone card. Caldera 1.1 Base

7. programs mysteriously segfaulting and exiting

8. Still another newbie question about libraries

9. Shared library segfaults on exit, including all functions doesn't

10. console unreadable after X exit/videomode on X exit problem

11. XFree86 4.0 & DGA problem

12. X 4.0.3 DGA problem

13. XFree86 DGA extension problems