Bug 78861 - SDL DGA segfaults on program start in DGA_SetVideoMode
SDL DGA segfaults on program start in DGA_SetVideoMode
Product: Red Hat Raw Hide
Classification: Retired
Component: SDL (Show other bugs)
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: wdovlrrw
Depends On:
  Show dependency treegraph
Reported: 2002-12-02 07:34 EST by Luca Barbieri
Modified: 2008-05-01 11:38 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-12-03 07:28:18 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Patch: tested and fixes the problem (423 bytes, patch)
2002-12-03 07:26 EST, Luca Barbieri
no flags Details | Diff

  None (edit)
Description Luca Barbieri 2002-12-02 07:34:17 EST
Description of Problem:
When an SDL program is started with SDL_VIDEODRIVER=dga, it segfaults in
The "dga" program (non SDL) works fine.

Version-Release number of selected component (if applicable):

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
Comment 1 Luca Barbieri 2002-12-02 14:12:24 EST
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);
	if ( mode == NULL ) {
		SDL_SetError("Unable to switch to requested mode");
	DGA_visualClass = modes[i].visualClass;
	memory_base = (Uint8 *)mode->data;
	memory_pitch = mode->mode.bytesPerScanline;
Comment 2 Luca Barbieri 2002-12-03 07:26:12 EST
Created attachment 87187 [details]
Patch: tested and fixes the problem
Comment 3 Luca Barbieri 2002-12-03 07:28:12 EST
The patch solves the problem on my system.
The bug is also present in upstream CVS, so please forward the patch.
Comment 4 Thomas Woerner 2002-12-11 08:55:53 EST
The bug is fixed in CVS, now.

Note You need to log in before you can comment on or make changes to this bug.