Bug 78861 - SDL DGA segfaults on program start in DGA_SetVideoMode
Summary: SDL DGA segfaults on program start in DGA_SetVideoMode
Alias: None
Product: Red Hat Raw Hide
Classification: Retired
Component: SDL
Version: 1.0
Hardware: i686
OS: Linux
Target Milestone: ---
Assignee: wdovlrrw
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2002-12-02 12:34 UTC by Luca Barbieri
Modified: 2008-05-01 15:38 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2002-12-03 12:28:18 UTC

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

Description Luca Barbieri 2002-12-02 12:34:17 UTC
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 19:12:24 UTC
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 12:26:12 UTC
Created attachment 87187 [details]
Patch: tested and fixes the problem

Comment 3 Luca Barbieri 2002-12-03 12:28:12 UTC
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 13:55:53 UTC
The bug is fixed in CVS, now.

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