extensions/vtab: fix i32 being passed as i64 across FFI boundary#2064
Merged
extensions/vtab: fix i32 being passed as i64 across FFI boundary#2064
Conversation
as nilskch points out in #1807, Rust 1.88.0 is stricter about alignment. because rust integers default to `i32`, we were casting a pointer to an `i32` as a pointer to an `i64` causing a panic when dereferenced due to misalignment as rust expects it to be 8 byte aligned.
jussisaurio
commented
Jul 12, 2025
| sql.as_ptr(), | ||
| args as *mut Value, | ||
| arg_count, | ||
| &last_insert_rowid as *const _ as *mut i64, |
Collaborator
Author
There was a problem hiding this comment.
btw let's try to avoid this as *const _ stuff, compiler would've caught this invalid cast otherwise
PThorpe92
approved these changes
Jul 13, 2025
penberg
reviewed
Jul 13, 2025
| let arg_count = args.len() as i32; | ||
| let args = args.as_ptr(); | ||
| let last_insert_rowid = 0; | ||
| let mut last_insert_rowid: i64 = 0; |
Collaborator
There was a problem hiding this comment.
usize is the architecture specific size to use herr
jussisaurio
added a commit
that referenced
this pull request
Jul 17, 2025
This PR updates to version Rust 1.88.0 ([Release notes](https://releases.rs/docs/1.88.0/)) and fixes all the clippy errors that come with the new Rust version. This is possible in the latest Rust version: ```rust if let Some(foo) = bar && foo.is_cool() { ... } ``` There are three complications in the migration (so far): - A BUNCH of Clippy warnings (mostly fixed in #1827) - Windows cross compilation failed; linking `advapi32` on windows fixes it - Since Rust 1.87.0, advapi32 is not linked by default anymore ([Release notes](https://github.com/rust- lang/rust/blob/master/RELEASES.md#compatibility-notes-1), [PR](rust-lang/rust#138233)) - Rust is more strict with FFIs and aligning pointers now. CI checks failed with error below - Fixed in #2064 ``` thread 'main' panicked at core/ext/vtab_xconnect.rs:64:25: misaligned pointer dereference: address must be a multiple of 0x8 but is 0x7ffd9d901554 ``` Closes #1807
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.
as nilskch points out in #1807, Rust 1.88.0 is stricter about alignment checks.
because rust integers default to
i32, we were casting a pointer to ani32as a pointer to ani64causing a panic when dereferenced due to misalignment as rust expects it to be 8 byte aligned.