Skip to content

Harden various parts of codebase - #1660

Merged
Bromeon merged 14 commits into
masterfrom
bugfix/many
Jul 21, 2026
Merged

Harden various parts of codebase#1660
Bromeon merged 14 commits into
masterfrom
bugfix/many

Conversation

@Bromeon

@Bromeon Bromeon commented Jul 19, 2026

Copy link
Copy Markdown
Member

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.

@Bromeon Bromeon added the bug label Jul 19, 2026
@GodotRust

Copy link
Copy Markdown

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1660

@Bromeon
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.
Bromeon added 2 commits July 21, 2026 17:03
`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
Bromeon force-pushed the bugfix/many branch 4 times, most recently from 6cfa998 to 2eb655f Compare July 21, 2026 18:39
Bromeon added 10 commits July 21, 2026 20:41
`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
Bromeon added this pull request to the merge queue Jul 21, 2026
Merged via the queue into master with commit e940567 Jul 21, 2026
17 checks passed
@Bromeon
Bromeon deleted the bugfix/many branch July 21, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude Code Review Report

2 participants