Harden various parts of codebase - #1660
Merged
Merged
Conversation
|
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1660 |
Bromeon
marked this pull request as ready for review
July 19, 2026 11:14
Both preconditions must hold: correct release order AND no remaining accessible/shared borrow. With `||`, `try_drop` could poison the cell or panic in `unset_inaccessible().unwrap()`. The missing `.unwrap()` and non-atomic check-then-drop in the blocking `try_drop` are intentional.
`byte_offset + $bytes` could wrap `usize` in release builds, passing the check and causing an OOB read/write into Godot memory via FFI.
Unconditionally called `maybe_inc_ref()` on a pointer that may reference an already-freed instance (e.g. destroyed on another thread), fatal during `Drop`. Add an `is_instance_valid()` guard, mirroring `Signal::object()`.
Bromeon
force-pushed
the
bugfix/many
branch
4 times, most recently
from
July 21, 2026 18:39
6cfa998 to
2eb655f
Compare
`to_string`, `on_notification`, `get_property`, `set_property`, `get_property_list`, `property_can_revert`, `property_get_revert` and `validate_property` run user code directly in `extern "C"` callbacks. An unhandled panic there hits the abort-on-unwind shim and takes down the whole process, instead of surfacing as an error. Wrap each in `handle_panic` and report failure to Godot. On failure, `get_property_list` returns an empty but non-null list.
`Option` overrode `from_variant` with a hand-rolled nil check, which missed the special-none case that `try_from_variant` handles (Godot 4.2 sends an empty `NodePath` instead of a nil variant when clearing an exported object property). Drop the override; the default forwards to `try_from_variant` and panics on error, which is what the old code did.
Previously kept registering methods/properties against a non-existent class.
`SeekFrom::End` compared length against the raw offset, rejecting valid positive offsets and missing large negative ones before the start.
Only the icon branch trimmed the string-literal quotes, so an icon-less button kept them. Trim once where the name is parsed.
The `INVALID_ARGUMENT` branch indexed `arg_types` with Godot's raw argument value, which can *theoretically* be out of range and panic. Use a checked `get` with a `NIL` fallback.
`spawn()` passed an already-boxed future into `add_task`, which boxed it again.
Old code returned `Some(NIL)` whenever any `NIL` key existed. Also keeps the number of FFI calls limited.
Bromeon
enabled auto-merge
July 21, 2026 18:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1642.
I fixed several things from the report. Some more academic ones I left out. There are also breaking changes which are worthwhile but need to wait for next minor version.