Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash if SDL_SetVideoMode larger than current Xrandr resolution. #80

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

Reported in version: HG 1.2
Reported for operating system, platform: Linux, All

Comments on the original bug report:

On 2006-02-21 05:56:08 +0000, Ryan C. Gordon wrote:

Date: Tue, 21 Feb 2006 01:05:53 +0100
To: "A list for developers using the SDL library." sdl@libsdl.org(includes
SDL-announce)
From: "Gerry JJ" trick@icculus.org
Subject: [SDL] BUG: Linux/X: Crash when setting video mode for higher XRandR
modes than current (X BadValue)

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

On 2006-03-22 06:15:56 +0000, Ryan C. Gordon wrote:

Latest CVS uses Xrandr when available and thus fixes this crash.

--ryan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant