The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
BUG: Linux/X: Crash when setting video mode for higher XRand
Gerry JJ
Guest

As the subject says, SDL fails setting the full screen video mode to
resolutions higher than current XRandR resolution setting (I'm using Linux
on an amd64 system, with Xorg 6.8.2 and the nvidia 1.0.8178 driver, if
that matters), in stead choosing to crash with a BadValue error from X.

For example, my system supports up to 1280x1024 and 1400x1050 resolutions,
but I usually use X with a 1024x768 xrandr setting (because of an old
monitor). For me this means that SDL crashes if setting fullscreen
resolutions higher than 1024x768. This is 100% reproducable. Also, SDL
does claim to support these higher modes when queried with SDL_ListModes().

Here's a small test program:

--- 8< ---
#include <SDL.h>
#include <stdio.h>

int main (int argc, char *argv[])
{
SDL_Rect **modes;
unsigned int i;

SDL_Init(SDL_INIT_VIDEO);

modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
if (!modes)
printf("All modes supported\n");
else if (modes == (SDL_Rect**)-1)
fprintf(stderr, "No supported modes!\n");
else for (i = 0; modes[i]; ++i)
printf("Supported mode: %ux%u\n", modes[i]->w, modes[i]->h);

if (!SDL_SetVideoMode(1024, 768, 0, SDL_FULLSCREEN))
fprintf(stderr, "Couldn't set video mode");
else
SDL_Delay(5000);

SDL_Quit();
}
--- 8< ---

Also, here's the output from xrandr on my system:

--- 8< ---
$ xrandr
SZ: Pixels Physical Refresh
0 1400 x 1050 ( 474mm x 356mm ) 60
1 1280 x 1024 ( 474mm x 356mm ) 60
2 1280 x 960 ( 474mm x 356mm ) 60
3 1152 x 864 ( 474mm x 356mm ) 75
*4 1024 x 768 ( 474mm x 356mm ) *85 75 70 60
5 832 x 624 ( 474mm x 356mm ) 75
6 800 x 600 ( 474mm x 356mm ) 85 75 72 60 56
7 700 x 525 ( 474mm x 356mm ) 60
8 640 x 512 ( 474mm x 356mm ) 60
9 640 x 480 ( 474mm x 356mm ) 85 75 73 60
10 720 x 400 ( 474mm x 356mm ) 85
11 640 x 400 ( 474mm x 356mm ) 85
12 576 x 432 ( 474mm x 356mm ) 75
13 640 x 350 ( 474mm x 356mm ) 85
14 512 x 384 ( 474mm x 356mm ) 85 75 70 60
15 416 x 312 ( 474mm x 356mm ) 75
16 400 x 300 ( 474mm x 356mm ) 85 75 72 60 56
17 320 x 240 ( 474mm x 356mm ) 85 75 73 60
18 320 x 200 ( 474mm x 356mm ) 85
19 320 x 175 ( 474mm x 356mm ) 85
Current rotation - normal
Current reflection - none
Rotations possible - normal
Reflections possible - none
--- 8< ---

When I run the test program on my system, it lists all of the modes listed
by xrandr above, ie the xrandr setting doesn't influence SDLs supported
modes list at all. (Also, modes available in several refresh rates is
listed more than once, once for each refresh rate, so that on my system
1024x768 is listed four times, 800x600 is listed five times, etc -- is
this a bug ?).

When run with xrandr set to 1024x768 (the resolution the test program
attempts to set) or higher, the test program works fine. The fullscreen
video mode is set correctly, and the program exits normally. In other
words, everything is just peachy.

When run with xrandr set to a mode lower than the resolution we attempt to
set, however (eg mode 6, 800x600), the test program aborts with the
following error (again, after listing all the modes, including 1024x768):

--- 8< ---
[...]
X Error of failed request: BadValue (integer parameter out of range for
operation)
Major opcode of failed request: 134 (XFree86-VidModeExtension)
Minor opcode of failed request: 10 (XF86VidModeSwitchToMode)
Value in failed request: 0x131
Serial number of failed request: 97
Current serial number in output stream: 99
--- 8< ---

Now, based on these results it doesn't look like SDL supports switching
video mode with XRandR. It'd be great if this could be added, but if
noone volunteers to do that (I'd do it myself, but I don't know how, and
don't have time to look into it at the moment -- maybe later though), the
list returned by SDL_ListModes etc should at least be fixed to take this
into account, so that programs don't try switching to higher modes and
crash like this.

- Gerry
BUG: Linux/X: Crash when setting video mode for higher XRand
Andras Salamon
Guest

On Tue, Feb 21, 2006 at 01:05:53AM +0100, Gerry JJ wrote:
Quote:
As the subject says, SDL fails setting the full screen video mode to
resolutions higher than current XRandR resolution setting (I'm using Linux
on an amd64 system, with Xorg 6.8.2 and the nvidia 1.0.8178 driver, if
that matters), in stead choosing to crash with a BadValue error from X.

This sounds similar to the crash on Mac OS X with setting windowed
resolution to a value greater than the current screen size (there the
problem is that the maximum value doesn't take into account the size of
the menu bar which the system insists on displaying).

-- Andras Salamon andras at dns.net
BUG: Linux/X: Crash when setting video mode for higher XRand
Ryan C. Gordon
Guest

Quote:
As the subject says, SDL fails setting the full screen video mode to
resolutions higher than current XRandR resolution setting (I'm using Linux
on an amd64 system, with Xorg 6.8.2 and the nvidia 1.0.8178 driver, if
that matters), in stead choosing to crash with a BadValue error from X.

I added this to bugzilla:
https://bugzilla.libsdl.org/show_bug.cgi?id=145

--ryan.
BUG: Linux/X: Crash when setting video mode for higher XRand
Christian Walther
Guest

Andras Salamon wrote:

Quote:
This sounds similar to the crash on Mac OS X with setting windowed
resolution to a value greater than the current screen size

Making windows bigger than the screen works just fine here on Mac OS X
10.4.5. Tested with the "showimage" sample and Eric's recent universal
binary frameworks, as well as with my own OpenGL app.

-Christian