Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

P1: Changing anti-aliasing from SMAA to FXAA, then Lighting, crashes under OpenGL

Open Beginner friendly
#7,916 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp
Domain
game-dev

Research direction

Start in gropenglshader.cpp, around lines 443–451, and trace the shader type lookup from the recompile-all loop after a Lighting change. Check how deleted slots are marked unused and how slot reuse handles that marker. Done when switching from SMAA to FXAA and then changing Lighting no longer crashes during shader recompilation; the issue gives these reproduction steps but names no test file.

Written by the indexing model from the issue text.

Description

Problem

Changing graphics options in the game's options menu can crash under OpenGL, on any mod. Set anti-aliasing to an SMAA mode, play with it for a moment, switch to an FXAA mode, then change the Lighting setting: the game crashes while it recompiles its shaders.

Switching away from SMAA deletes the SMAA shaders and marks their slots as unused, but the recompile that runs after a Lighting change walks every slot, including the deleted ones. For a deleted slot the shader type lookup returns nothing, and the compile code uses that result without a check (gropenglshader.cpp, around line 443-451).

Steps to reproduce

  1. FSO master (tested on 12a36dc1a with an ASan debug build; gropenglshader.cpp is unchanged on current master 76219fd1e), Linux, OpenGL, MediaVPs 5.0.2. Any mission.
  2. In the options menu, set Anti-Aliasing to SMAA Low. Return to the mission and fly for a few seconds, so the SMAA shaders get compiled.
  3. Set Anti-Aliasing to FXAA Low. Return to the mission for a few seconds.
  4. Change Lighting (for example Ultra to High).

I drove the three option changes through the scripting options API (opt.Options, persistChanges), which is the same option system the menu uses. Changing SMAA to FXAA in a single step, with no frame rendered in SMAA, did not crash, because no SMAA shader had been compiled yet.

Expected vs. actual behavior

Expected: the shaders recompile and the game continues with the new lighting level.

Actual: the debug build stops on Assert(sdr_info != nullptr) in the shader compile path, called from the recompile-all loop. A release build has no assert there and reads through the null pointer (from reading the code).

Proposed fixes

  1. Skip deleted slots in the recompile loop. In gr_opengl_recompile_all_shaders, skip any slot whose shader type is the "unused" marker, the same check the slot-reuse code already makes. One line.
  2. Erase the slot instead of marking it. Have shader deletion remove the entry from the shader list (and its lookup map) so nothing that walks the list can see it. Cleaner, but every stored shader index after the removed one would shift, so it needs care.
  3. Make the compile function refuse an unknown type. Return early with an error when the type lookup fails, so any future caller that reaches a deleted slot is safe as well.
Dominant language
C++
Stars
488
Forks
184
Avg merge
2d 9h
Merged PRs (30d)
40

Getting set up

We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from scp-fs2open/fs2open.github.com

All issues in scp-fs2open/fs2open.github.com

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.