Skip to content

Commit 9d8a039

Browse files
authored
Merge branch 'model-checking:main' into rapx-verify-std
2 parents 21e157d + c69b9b9 commit 9d8a039

File tree

388 files changed

+13869
-16818
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

388 files changed

+13869
-16818
lines changed

.github/workflows/flux.yml

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ on:
88
branches: [main]
99

1010
env:
11-
FIXPOINT_VERSION: "556104ba5508891c357b0bdf819ce706e93d9349"
12-
FLUX_VERSION: "f5e57bec353e2eb3550d2b7ba086462264dfa290"
11+
FLUX_VERSION: "6b080b32801f923bfb590ac48e729de38f829f21"
12+
FIXPOINT_VERSION: "nightly-10-15-2025"
1313

1414
jobs:
1515
check-flux-on-core:
@@ -25,27 +25,22 @@ jobs:
2525
echo ~/.cargo/bin >> $GITHUB_PATH
2626
echo ~/.local/bin >> $GITHUB_PATH
2727
28-
- name: Cache fixpoint
29-
uses: actions/cache@v4
30-
id: cache-fixpoint
31-
with:
32-
path: ~/.local/bin/fixpoint
33-
key: fixpoint-bin-${{ runner.os }}-${{ env.FIXPOINT_VERSION }}
28+
- name: Download and install fixpoint
29+
run: |
30+
set -e
31+
NAME="fixpoint-x86_64-linux-gnu.tar.gz"
32+
URL="https://github.com/ucsd-progsys/liquid-fixpoint/releases/download/${FIXPOINT_VERSION}/${NAME}"
3433
35-
- name: Install Haskell
36-
if: steps.cache-fixpoint.outputs.cache-hit != 'true'
37-
uses: haskell-actions/setup@v2.7.0
38-
with:
39-
enable-stack: true
40-
stack-version: "2.15.7"
34+
echo "Downloading from $URL"
35+
curl -fsSL --retry 3 -o "$NAME" "$URL"
4136
42-
- name: Install fixpoint
43-
if: steps.cache-fixpoint.outputs.cache-hit != 'true'
44-
run: |
45-
git clone https://github.com/ucsd-progsys/liquid-fixpoint.git
46-
cd liquid-fixpoint
47-
git checkout $FIXPOINT_VERSION
48-
stack install --fast --flag liquid-fixpoint:-link-z3-as-a-library
37+
echo "Extracting archive"
38+
tar -xzf "$NAME"
39+
mkdir -p ~/.local/bin
40+
cp fixpoint ~/.local/bin/fixpoint
41+
42+
echo "Cleaning up"
43+
rm -f "$NAME"
4944
5045
- name: Install Z3
5146
uses: cda-tum/setup-z3@v1.6.1

.github/workflows/kani-metrics.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ defaults:
1111

1212
jobs:
1313
update-kani-metrics:
14+
permissions:
15+
contents: write
16+
pull-requests: write
1417
if: github.repository == 'model-checking/verify-rust-std'
1518
runs-on: ubuntu-latest
1619

.github/workflows/update-subtree.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ defaults:
1111

1212
jobs:
1313
update-subtree-library:
14+
permissions:
15+
contents: write
16+
pull-requests: write
1417
if: github.repository == 'model-checking/verify-rust-std'
1518
# Changing the host platform may alter the libgit2 version as used by
1619
# splitsh-lite, which will require changing the version of git2go.
@@ -214,16 +217,12 @@ jobs:
214217
215218
# Try to automatically patch the VeriFast proofs
216219
pushd verifast-proofs
217-
if bash ./patch-verifast-proofs.sh; then
218-
if ! git diff --quiet; then
219-
git -c user.name=gitbot -c user.email=git@bot \
220-
commit . -m "Update VeriFast proofs"
221-
else
222-
# The original files have not changed; no updates to the VeriFast proofs are necessary.
223-
true
224-
fi
220+
./patch-verifast-proofs.sh
221+
if ! git diff --quiet; then
222+
git -c user.name=gitbot -c user.email=git@bot \
223+
commit . -m "Update VeriFast proofs"
225224
else
226-
# Patching the VeriFast proofs failed; requires manual intervention.
225+
# The original files have not changed; no updates to the VeriFast proofs are necessary.
227226
true
228227
fi
229228
popd

.github/workflows/verifast-negative.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,5 @@ jobs:
2727
- name: Checkout Repository
2828
uses: actions/checkout@v4
2929

30-
- name: Install VeriFast
31-
run: |
32-
cd ~
33-
curl -OL https://github.com/verifast/verifast/releases/download/25.07/verifast-25.07-linux.tar.gz
34-
# https://github.com/verifast/verifast/attestations/8998468
35-
echo '48d2c53b4a6e4ba6bf03bd6303dbd92a02bfb896253c06266b29739c78bad23b verifast-25.07-linux.tar.gz' | shasum -a 256 -c
36-
tar xf verifast-25.07-linux.tar.gz
37-
38-
- name: Install the Rust toolchain used by VeriFast
39-
run: rustup toolchain install nightly-2025-04-09
40-
4130
- name: Run VeriFast Verification
42-
run: |
43-
export PATH=~/verifast-25.07/bin:$PATH
44-
cd verifast-proofs
45-
bash check-verifast-proofs-negative.sh
31+
run: verifast-proofs/check-verifast-proofs-negative.sh

.github/workflows/verifast.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,8 @@ jobs:
2424
- name: Checkout Repository
2525
uses: actions/checkout@v4
2626

27-
- name: Install VeriFast
28-
run: |
29-
cd ~
30-
curl -OL https://github.com/verifast/verifast/releases/download/25.07/verifast-25.07-linux.tar.gz
31-
# https://github.com/verifast/verifast/attestations/8998468
32-
echo '48d2c53b4a6e4ba6bf03bd6303dbd92a02bfb896253c06266b29739c78bad23b verifast-25.07-linux.tar.gz' | shasum -a 256 -c
33-
tar xf verifast-25.07-linux.tar.gz
34-
35-
- name: Install the Rust toolchain used by VeriFast
36-
run: rustup toolchain install nightly-2025-04-09
37-
3827
- name: Run VeriFast Verification
39-
run: |
40-
export PATH=~/verifast-25.07/bin:$PATH
41-
cd verifast-proofs
42-
bash check-verifast-proofs.sh
28+
run: verifast-proofs/check-verifast-proofs.sh
4329

4430
notify-btj:
4531
name: Notify @btj

doc/src/challenges/0028-flt2dec.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Challenge 28: Verify float to decimal conversion module
2+
3+
- **Status:** *Open*
4+
- **Solution:** *Option field to point to the PR that solved this challenge.*
5+
- **Tracking Issue:** [#524](https://github.com/model-checking/verify-rust-std/issues/524)
6+
- **Start date:** *2026/01/01*
7+
- **End date:** *2026/08/31*
8+
- **Reward:** *5,000 USD*
9+
10+
-------------------
11+
12+
13+
## Goal
14+
15+
The goal of this challenge is to verify the [flt2dec](https://doc.rust-lang.org/src/core/num/flt2dec/mod.rs.html) module, which provides functions for converting floating point numbers to decimals. To do this, it implements both the Dragon and Grisu families of algorithms.
16+
17+
## Motivation
18+
19+
Given that converting floats to decimals correctly is a relatively costly operation, the standard library’s flt2dec module employs unsafe code to enable performance-enhancing operations that are otherwise not allowed in safe Rust (e.g., lifetime laundering to get around borrow-checker restrictions). Functions from this module are primarily invoked whenever attempting to represent floats in a human-readable format, making this a potentially highly-used module.
20+
21+
## Description
22+
23+
All of the functions targeted in this challenge are safe functions whose bodies contain unsafe code. This challenge is thus centered around proving well-encapsulation, which here mainly means showing that calls to variants of assume_init() are only performed on fully-initialized structures, and that the lifetime laundering does not cause undefined behaviour.
24+
25+
### Success Criteria
26+
27+
The following functions contain unsafe code in their bodies but are not themselves marked unsafe. All of these should be proven unconditionally safe, or safety contracts should be added:
28+
29+
| Function | Location |
30+
|---------|---------|
31+
| `digits_to_dec_str` | `flt2dec` |
32+
| `digits_to_exp_str` | `flt2dec` |
33+
| `to_shortest_str` | `flt2dec` |
34+
| `to_shortest_exp_str` | `flt2dec` |
35+
| `to_exact_exp_str` | `flt2dec` |
36+
| `to_exact_fixed_str` | `flt2dec` |
37+
| `format_shortest_opt` | `flt2dec::strategy::grisu` |
38+
| `format_shortest` | `flt2dec::strategy::grisu` |
39+
| `format_exact_opt` | `flt2dec::strategy::grisu` |
40+
| `format_exact` | `flt2dec::strategy::grisu` |
41+
| `format_shortest` | `flt2dec::strategy::dragon` |
42+
| `format_exact` | `flt2dec::strategy::dragon` |
43+
44+
For functions taking inputs of generic type 'T', the proofs can be limited to primitive types only.
45+
46+
*List of UBs*
47+
48+
In addition to any properties called out as SAFETY comments in the source code, all proofs must automatically ensure the absence of the following [undefined behaviors](https://github.com/rust-lang/reference/blob/142b2ed77d33f37a9973772bd95e6144ed9dce43/src/behavior-considered-undefined.md):
49+
* Accessing (loading from or storing to) a place that is dangling or based on a misaligned pointer.
50+
* Invoking undefined behavior via compiler intrinsics.
51+
* Mutating immutable bytes.
52+
* Producing an invalid value.
53+
54+
Note: All solutions to verification challenges need to satisfy the criteria established in the [challenge book](../general-rules.md)
55+
in addition to the ones listed above.

doc/src/challenges/0029-boxed.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Challenge 29: Safety of boxed
2+
3+
- **Status:** *Open*
4+
- **Solution:** *Option field to point to the PR that solved this challenge.*
5+
- **Tracking Issue:** [#526](https://github.com/model-checking/verify-rust-std/issues/526)
6+
- **Start date:** *2026/01/01*
7+
- **End date:** *2026/12/31*
8+
- **Reward:** *15,000 USD*
9+
10+
-------------------
11+
12+
13+
## Goal
14+
15+
The goal of this challenge is to verify the [boxed](https://doc.rust-lang.org/std/boxed/index.html) module, which implements the Box family of types (which includes Box and other related types such as ThinBox). A Box is a type of smart pointer that points to a uniquely-owned heap allocation for arbitrary types.
16+
17+
## Motivation
18+
19+
A Box allows the storage of data on the heap rather than the stack. This has several applications, a common [example](https://doc.rust-lang.org/book/ch15-01-box.html#enabling-recursive-types-with-boxes) being for using dynamically-sized types in contexts requiring an exact size (e.g., recursive types). While this type is useful and diverse in its applications, it also extensively uses unsafe code, meaning it is important to verify that this module is free of undefined behaviour.
20+
21+
### Success Criteria
22+
23+
All the following unsafe functions must be annotated with safety contracts and the contracts have been verified:
24+
25+
| Function | Location |
26+
|---------|---------|
27+
| `Box<mem::MaybeUninit<T>, A>::assume_init` | `alloc::boxed` |
28+
| `Box<[mem::MaybeUninit<T>], A>::assume_init` | `alloc::boxed` |
29+
| `Box<T>::from_raw` | `alloc::boxed` |
30+
| `Box<T>::from_non_null` | `alloc::boxed` |
31+
| `Box<T, A>::from_raw_in` | `alloc::boxed` |
32+
| `Box<T, A>::from_non_null_in` | `alloc::boxed` |
33+
| `<dyn Error>::downcast_unchecked` | `alloc::boxed::convert` |
34+
| `<dyn Error + Send>::downcast_unchecked` | `alloc::boxed::convert` |
35+
| `<dyn Error + Send + Sync>::downcast_unchecked` | `alloc::boxed::convert` |
36+
37+
The following functions contain unsafe code in their bodies but are not themselves marked unsafe. At least 75% of these should be proven unconditionally safe, or safety contracts should be added:
38+
39+
| Function | Location |
40+
|---------|---------|
41+
| `Box<T, A>::new_in` | `alloc::boxed` |
42+
| `Box<T, A>::try_new_in` | `alloc::boxed` |
43+
| `Box<T, A>::try_new_uninit_in` | `alloc::boxed` |
44+
| `Box<T, A>::try_new_zeroed_in` | `alloc::boxed` |
45+
| `Box<T, A>::into_boxed_slice` | `alloc::boxed` |
46+
| `Box<[T]>::new_uninit_slice` | `alloc::boxed` |
47+
| `Box<[T]>::new_zeroed_slice` | `alloc::boxed` |
48+
| `Box<[T]>::try_new_uninit_slice` | `alloc::boxed` |
49+
| `Box<[T]>::try_new_zeroed_slice` | `alloc::boxed` |
50+
| `Box<[T]>::into_array` | `alloc::boxed` |
51+
| `Box<T, A>::new_uninit_slice_in` | `alloc::boxed` |
52+
| `Box<T, A>::new_zeroed_slice_in` | `alloc::boxed` |
53+
| `Box<T, A>::try_new_uninit_slice_in` | `alloc::boxed` |
54+
| `Box<T, A>::try_new_zeroed_slice_in` | `alloc::boxed` |
55+
| `Box<mem::MaybeUninit<T>, A>::write` | `alloc::boxed` |
56+
| `Box<T>::into_non_null` | `alloc::boxed` |
57+
| `Box<T, A>::into_raw_with_allocator` | `alloc::boxed` |
58+
| `Box<T, A>::into_non_null_with_allocator` | `alloc::boxed` |
59+
| `Box<T, A>::into_unique` | `alloc::boxed` |
60+
| `Box<T, A>::leak` | `alloc::boxed` |
61+
| `Box<T, A>::into_pin` | `alloc::boxed` |
62+
| `<Box<T, A> as Drop>::drop` | `alloc::boxed` |
63+
| `<Box<T> as Default>::default` | `alloc::boxed` |
64+
| `<Box<str> as Default>::default` | `alloc::boxed` |
65+
| `<Box<T, A> as Clone>::clone` | `alloc::boxed` |
66+
| `<Box<str> as Clone>::clone` | `alloc::boxed` |
67+
| `<Box<[T]> as BoxFromSlice<T>>::from_slice` | `alloc::boxed::convert` |
68+
| `<Box<str> as From<&str>>::from` | `alloc::boxed::convert` |
69+
| `<Box<[u8], A> as From<Box<str, A>>>::from` | `alloc::boxed::convert` |
70+
| `<Box<[T; N]> as TryFrom<Box<[T]>>>::try_from` | `alloc::boxed::convert` |
71+
| `<Box<[T; N]> as TryFrom<Box<T>>>::try_from` | `alloc::boxed::convert` |
72+
| `Box<dyn Any, A>::downcast` | `alloc::boxed::convert` |
73+
| `Box<dyn Any + Send, A>::downcast` | `alloc::boxed::convert` |
74+
| `Box<dyn Any + Send + Sync, A>::downcast` | `alloc::boxed::convert` |
75+
| `<dyn Error>::downcast` | `alloc::boxed::convert` |
76+
| `<dyn Error + Send>::downcast` | `alloc::boxed::convert` |
77+
| `<dyn Error + Send + Sync>::downcast` | `alloc::boxed::convert` |
78+
| `<ThinBox<T> as Deref>::deref` | `alloc::boxed::thin` |
79+
| `<ThinBox<T> as DerefMut>::deref_mut` | `alloc::boxed::thin` |
80+
| `<ThinBox<T> as Drop>::drop` | `alloc::boxed::thin` |
81+
| `ThinBox<T>::meta` | `alloc::boxed::thin` |
82+
| `ThinBox<T>::with_header` | `alloc::boxed::thin` |
83+
| `WithHeader<H>::new` | `alloc::boxed::thin` |
84+
| `WithHeader<H>::try_new` | `alloc::boxed::thin` |
85+
| `WithHeader<H>::new_unsize_zst` | `alloc::boxed::thin` |
86+
| `WithHeader<H>::header` | `alloc::boxed::thin` |
87+
88+
For functions taking inputs of generic type 'T', the proofs can be limited to primitive types only.
89+
90+
*List of UBs*
91+
92+
In addition to any properties called out as SAFETY comments in the source code, all proofs must automatically ensure the absence of the following [undefined behaviors](https://github.com/rust-lang/reference/blob/142b2ed77d33f37a9973772bd95e6144ed9dce43/src/behavior-considered-undefined.md):
93+
* Accessing (loading from or storing to) a place that is dangling or based on a misaligned pointer.
94+
* Invoking undefined behavior via compiler intrinsics.
95+
* Mutating immutable bytes.
96+
* Producing an invalid value.
97+
98+
Note: All solutions to verification challenges need to satisfy the criteria established in the [challenge book](../general-rules.md)
99+
in addition to the ones listed above.

library/Cargo.lock

Lines changed: 12 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

library/alloc/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ safety = { path = "../contracts/safety" }
2323
compiler-builtins-mem = ['compiler_builtins/mem']
2424
compiler-builtins-c = ["compiler_builtins/c"]
2525
compiler-builtins-no-f16-f128 = ["compiler_builtins/no-f16-f128"]
26-
# Make panics and failed asserts immediately abort without formatting any message
27-
panic_immediate_abort = ["core/panic_immediate_abort"]
2826
# Choose algorithms that are optimized for binary size instead of runtime performance
2927
optimize_for_size = ["core/optimize_for_size"]
3028

library/alloc/src/alloc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,12 @@ pub const fn handle_alloc_error(layout: Layout) -> ! {
408408
}
409409
}
410410

411-
#[cfg(not(feature = "panic_immediate_abort"))]
411+
#[cfg(not(panic = "immediate-abort"))]
412412
{
413413
core::intrinsics::const_eval_select((layout,), ct_error, rt_error)
414414
}
415415

416-
#[cfg(feature = "panic_immediate_abort")]
416+
#[cfg(panic = "immediate-abort")]
417417
ct_error(layout)
418418
}
419419

0 commit comments

Comments
 (0)