Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glib: fix UB in VariantStrIter::impl_get #1343

Merged
merged 1 commit into from
Mar 30, 2024
Merged

glib: fix UB in VariantStrIter::impl_get #1343

merged 1 commit into from
Mar 30, 2024

Conversation

decathorpe
Copy link
Contributor

Passing an immutable reference (&p) to a function that mutates the data behind the pointer violates Rust's invariants.

This causes multiple tests in the test suite to crash when compiling it with optimizations (either --release mode or with opt-level of 2 or 3) with recent Rust versions, which is easy to reproduce, especially with nightly Rust:

$ cargo +nightly test --release --package glib
(...)
error: test failed, to rerun pass `--lib`
Caused by:
  process didn't exit successfully: (...) (signal: 11, SIGSEGV: invalid memory reference)

Looks like this wasn't caught earlier because the wrapped C function is variadic and there's less type checking happening because of that.

Passing an immutable reference (&p) to a function that mutates the
data behind the pointer violates Rust's invariants.
@sdroege sdroege merged commit 05dff0e into gtk-rs:master Mar 30, 2024
47 of 48 checks passed
@sdroege sdroege added the needs-backport PR needs backporting to the current stable branch label Mar 30, 2024
@sdroege
Copy link
Member

sdroege commented Mar 30, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported PR was backported to the current stable branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants