# X Error BadMatch from RRSetCrtcGamma on Linux with latest NVidia driver

**URL:** <https://discourse.glfw.org/t/x-error-badmatch-from-rrsetcrtcgamma-on-linux-with-latest-nvidia-driver/888>\
**Category:** support\
**Created:** [April 5, 2017, 7:19am UTC](https://discourse.glfw.org/t/x-error-badmatch-from-rrsetcrtcgamma-on-linux-with-latest-nvidia-driver/888 "2017-04-05T07:19:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fractilegames](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/fractilegames/32/114_2.png) [@fractilegames](https://discourse.glfw.org/u/fractilegames)\
**Post date:** [April 5, 2017, 7:19am UTC](https://discourse.glfw.org/t/x-error-badmatch-from-rrsetcrtcgamma-on-linux-with-latest-nvidia-driver/888/1 "2017-04-05T07:19:55Z")

</div>

I got bug report for my game saying that the game crashes when starting in full-screen mode. I can’t reproduce the issue myself, but I do have fairly good logs from the incident.

These are the last words of the executable:

X Error of failed request: BadMatch (invalid parameter attributes)  
Major opcode of failed request: 140 (RANDR)  
Minor opcode of failed request: 24 (RRSetCrtcGamma)  
Serial number of failed request: 212  
Current serial number in output stream: 213

The game was run on 64-bit Antergos Linux on Intel CPU and GeForce GTX 980 Ti graphics card using the latest proprietary drivers (378.13).

Any ideas what might be causing this?

---

<div class="post-metadata">

**Author:** ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)\
**Post date:** [April 5, 2017, 1:31pm UTC](https://discourse.glfw.org/t/x-error-badmatch-from-rrsetcrtcgamma-on-linux-with-latest-nvidia-driver/888/2 "2017-04-05T13:31:14Z")

</div>

Are you using `glfwSetGamma` or `glfwSetGammaRamp`?

---

<div class="post-metadata">

**Author:** ![fractilegames](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/fractilegames/32/114_2.png) [@fractilegames](https://discourse.glfw.org/u/fractilegames)\
**Post date:** [April 5, 2017, 3:10pm UTC](https://discourse.glfw.org/t/x-error-badmatch-from-rrsetcrtcgamma-on-linux-with-latest-nvidia-driver/888/3 "2017-04-05T15:10:23Z")

</div>

I use glfwSetGamma() if game is launched full-screen.

---

<div class="post-metadata">

**Author:** ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)\
**Post date:** [April 5, 2017, 3:36pm UTC](https://discourse.glfw.org/t/x-error-badmatch-from-rrsetcrtcgamma-on-linux-with-latest-nvidia-driver/888/4 "2017-04-05T15:36:20Z")

</div>

At first glance, the error seems to be caused by GLFW trying to set a ramp of a different size than the current one, [which RandR prohibits](https://cgit.freedesktop.org/xorg/proto/randrproto/plain/randrproto.txt) but GLFW doesn’t check for. If so, you can fix it on your end right away by building your own ramp of the current size and setting that with `glfwSetGammaRamp`. Check the implementation of `glfwSetGamma` for any details, as it’s just a wrapper for the former function.

I’ll fix this in master asap but won’t have much coding time this and next week.

---

<div class="post-metadata">

**Author:** ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)\
**Post date:** [April 5, 2017, 4:01pm UTC](https://discourse.glfw.org/t/x-error-badmatch-from-rrsetcrtcgamma-on-linux-with-latest-nvidia-driver/888/5 "2017-04-05T16:01:09Z")

</div>

The `BadMatch` should be fixed now.

[https://github.com/glfw/glfw/commit/66b16f1fc1cfb1ee68ccbbc09e56646e3ab1e6fe](https://github.com/glfw/glfw/commit/66b16f1fc1cfb1ee68ccbbc09e56646e3ab1e6fe)

This still leaves `glfwSetGamma` potentially producing ramps of invalid sizes on RandR, but the documentation specifies a static ramp size so I’m not sure yet which choice breaks the least code.

---

<div class="post-metadata">

**Author:** ![fractilegames](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/fractilegames/32/114_2.png) [@fractilegames](https://discourse.glfw.org/u/fractilegames)\
**Post date:** [April 5, 2017, 5:10pm UTC](https://discourse.glfw.org/t/x-error-badmatch-from-rrsetcrtcgamma-on-linux-with-latest-nvidia-driver/888/6 "2017-04-05T17:10:26Z")

</div>

Thank you for the help! I wasn’t expecting to find a solution this fast 😄

According to NVidia driver change log ([http://www.nvidia.com/download/driverResults.aspx/101818/en-us](http://www.nvidia.com/download/driverResults.aspx/101818/en-us)), it now uses 1024 entry gamma ramp, so this is almost certainly the cause of my error.
