Description of Problem: When an SDL program is started with SDL_VIDEODRIVER=dga, it segfaults in DGA_SetVideoMode. The "dga" program (non SDL) works fine. Version-Release number of selected component (if applicable): SDL-1.2.4-5 XFree86-4.2.99.2-0.20021122.2 How Reproducible: Every time. Steps to Reproduce: 1. Install a 2D SDL program (reproduced with frozen-bubble and VisualBoyAdvance) 2. Run it as root with SDL_VIDEODRIVER=dga Actual Results: Segfault. A core dump shows that it happens at 0x400779bc in DGA_SetVideoMode () from /usr/lib/libSDL-1.2.so.0. Expected Results: The program should work correctly. Additional Information: 0x400779a8 <DGA_SetVideoMode+232>: test %edi,%edi 0x400779aa <DGA_SetVideoMode+234>: je 0x40077c78 <DGA_SetVideoMode+952> 0x400779b0 <DGA_SetVideoMode+240>: mov 0x8(%ebp),%ecx 0x400779b3 <DGA_SetVideoMode+243>: mov 0x290(%ecx),%edx 0x400779b9 <DGA_SetVideoMode+249>: mov 0xffffffe4(%ebp),%ecx 0x400779bc <DGA_SetVideoMode+252>: movswl 0x3c(%esi,%ecx,1),%eax eax 0x1 1 ecx 0xe038 57400 edx 0x8212f30 136392496 ebx 0x4008eedc 1074327260 esp 0xbffff2d0 0xbffff2d0 ebp 0xbffff308 0xbffff308 esi 0x822f328 136508200 edi 0x821d928 136436008 eip 0x400779bc 0x400779bc eflags 0x210206 2163206
The problem is probably the use of modes[i] after modes has been freed. The code should either use mode-> or delay freeing modes. I have not tested whether fixing this solves the problem. /* Set the video mode */ mode = SDL_NAME(XDGASetMode)(DGA_Display, DGA_Screen, modes[i].num); XFree(modes); if ( mode == NULL ) { SDL_SetError("Unable to switch to requested mode"); return(NULL); } DGA_visualClass = modes[i].visualClass; memory_base = (Uint8 *)mode->data; memory_pitch = mode->mode.bytesPerScanline;
Created attachment 87187 [details] Patch: tested and fixes the problem
The patch solves the problem on my system. The bug is also present in upstream CVS, so please forward the patch.
The bug is fixed in CVS, now.