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

Get Stack Borrows mostly working #36

Merged
merged 1 commit into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ jobs:
rustup toolchain install nightly --component miri
rustup override set nightly
cargo miri setup
- name: Test with Miri
- name: Test with Miri Stack Borrows
run: cargo miri test
- name: Test with Miri Tree Borrows
run: cargo miri test
env:
MIRIFLAGS: -Zmiri-tree-borrows
8 changes: 5 additions & 3 deletions src/dlmalloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,11 +1023,11 @@ impl<A: Allocator> Dlmalloc<A> {
(*chunk).child[1] = ptr::null_mut();
let chunkc = TreeChunk::chunk(chunk);
if !self.treemap_is_marked(idx) {
self.mark_treemap(idx);
*h = chunk;
(*chunk).parent = h.cast(); // TODO: dubious?
(*chunkc).next = chunkc;
(*chunkc).prev = chunkc;
self.mark_treemap(idx);
} else {
let mut t = *h;
let mut k = size << leftshift_for_tree_index(idx);
Expand Down Expand Up @@ -1519,8 +1519,7 @@ impl<A: Allocator> Dlmalloc<A> {
if !cfg!(debug_assertions) {
return;
}
let tb = self.treebin_at(idx);
let t = *tb;
let t = *self.treebin_at(idx);
let empty = self.treemap & (1 << idx) == 0;
if t.is_null() {
debug_assert!(empty);
Expand Down Expand Up @@ -1563,6 +1562,9 @@ impl<A: Allocator> Dlmalloc<A> {
debug_assert!(head.is_null());
head = u;
debug_assert!((*u).parent != u);
// TODO: unsure why this triggers UB in stacked borrows in MIRI
// (works in tree borrows though)
#[cfg(not(miri))]
debug_assert!(
(*(*u).parent).child[0] == u
|| (*(*u).parent).child[1] == u
Expand Down