We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2566 - When a monitor is disabled, GetNumDisplayModes crashes with X error BadRRCrtc
Summary: When a monitor is disabled, GetNumDisplayModes crashes with X error BadRRCrtc
Status: ASSIGNED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.3
Hardware: x86_64 Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-31 19:49 UTC by Gabríel Arthúr Pétursson
Modified: 2017-08-14 13:04 UTC (History)
0 users

See Also:


Attachments
A minimal reproducible test case (1.38 KB, text/x-csrc)
2014-05-31 19:49 UTC, Gabríel Arthúr Pétursson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabríel Arthúr Pétursson 2014-05-31 19:49:26 UTC
Created attachment 1666 [details]
A minimal reproducible test case

When querying the number of display modes, the SDL_GetNumDisplayModes function may crash the application under the condition that the monitor in question has been disabled since SDL initialization.

== Steps to reproduce ==

A dual-monitor setup is required to reproduce this bug. Having more than two monitors, while not tested, should trigger the bug too.

 1) Initialize SDL and the video subsystem.
 2) Get the number of displays with SDL_GetNumVideoDisplays.
 3) Disable one of your monitors. Simply turning off your monitor is not sufficient.
 4) For each display, get its number of display modes with SDL_GetNumDisplayModes.

For step 3, I have used the nvidia-settings tool to disable one of the monitors. Other tools should work as well.

== Actual results ==

When the monitor that has been disabled is queried, the application should crash with an error message similar to the following.

 X Error of failed request:  BadRRCrtc (invalid Crtc parameter)
   Major opcode of failed request:  140 (RANDR)
   Minor opcode of failed request:  20 (RRGetCrtcInfo)
   Crtc id in failed request: 0x0
   Serial number of failed request:  171
   Current serial number in output stream:  171

A minimal reproducible test case is attached with this bug report.

== Expected results ==

The SDL_GetNumDisplayModes function should return a negative error code on failure, with SDL_GetError indicating that the monitor is no longer active.

== Build Date & Hardware ==

Built from source tarball at 2014-04-27 with gcc 4.8.2 on Debian Testing.
Comment 1 Ryan C. Gordon 2015-02-19 06:32:14 UTC
Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry
if you got a lot of email from this. This is to help me sort through some bugs
in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4,
though!