Skip to content

Fix use-after free issues with shader programs - #84

Merged
Meziu merged 3 commits into
rust3ds:mainfrom
Terpsichord:main
Jun 15, 2026
Merged

Fix use-after free issues with shader programs#84
Meziu merged 3 commits into
rust3ds:mainfrom
Terpsichord:main

Conversation

@Terpsichord

Copy link
Copy Markdown
Contributor

This should fix both use-after-errors mentioned in #53, by making shader::Program own the shader::Library that it uses, and by making shader::Library own the underlying bytes of the compiled shader.

@Meziu

Meziu commented Apr 15, 2026

Copy link
Copy Markdown
Member

The only thing I want to correct is the absorption of "Entrypoint" into "Library", while they are supposed to be separate concepts. Afaik, multiple dvlb entries can coexist in a compiled shader binary, even though that is basically never used (and rarely useful) in a real program.

Either way, I'm fine with the changes.

@Terpsichord

Copy link
Copy Markdown
Contributor Author

I've updated it so that Library::get now takes ownership of the Library, and added a new get_shared method which uses Rc to allow multiple entrypoints from the same library. Library now uses a new MaybeRc enum to avoid any overhead from Rc in the 99% of cases where it's not needed.

Also while creating the examples, I noticed that there's no method to get the location of a uniform in the geometry shader so I've added that too.

@Meziu
Meziu merged commit c86c611 into rust3ds:main Jun 15, 2026
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

Successfully merging this pull request may close these issues.

2 participants