miri: enforce proper types for c-variadic arguments in shims - #161734
miri: enforce proper types for c-variadic arguments in shims#161734RalfJung wants to merge 2 commits into
Conversation
|
Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri These commits modify the If this was unintentional then you should revert the changes before this PR is merged.
cc @rust-lang/miri Some changes occurred to the CTFE machinery Some changes occurred to the CTFE / Miri interpreter |
|
r? @mejrs rustbot has assigned @mejrs. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
|
r? @saethlin |
8cec627 to
888931c
Compare
This comment was marked as resolved.
This comment was marked as resolved.
3a365e2 to
1b22718
Compare
|
@bors try jobs=aux |
miri: enforce proper types for c-variadic arguments in shims try-job: *aux*
This comment has been minimized.
This comment has been minimized.
1b22718 to
329d83d
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This adds proper type checks for c-variadic argument handling in Miri shims. So far we would have ICEd for many type mismatches since the innards of the interpreter generally assume that things are well-typed. The checks are are using are the same as for
next_arg.This uncovered some interesting points:
&mutas equivalent to*mut. We don't allow&mutas a type innext_argbut we do allow it for c-variadic calls, so this change also affects a bit more code in const-eval (if the caller passes an&mutand the callee expects a*mut). Even CFI is okay with treating&mutand*mutas equivalent so this should be fine. Cc @folkertdevlibc::timespec. A program with a libc dependency has two copies of libc (one in the sysroot, and the normal dependency), leading to Miri seeing a type mismatch. C generally considers two copies of the same type to be identical, so I implemented logic that does the same: the names of the type, and the names and types of all fields, must be identical. I then also used that logic for the normal ABI checks, where it will also help since we had similar trouble there in the past (that we had to find other work-arounds for).