Skip to content

Commit

Permalink
Add a test to reproduce the issue. Remove the assertion.
Browse files Browse the repository at this point in the history
  • Loading branch information
qinsoon committed Sep 25, 2020
1 parent 02ca036 commit 5512189
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 3 deletions.
10 changes: 9 additions & 1 deletion .github/scripts/ci-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@ set -xe

cargo test --features nogc
cargo test --features semispace
python examples/build.py
python examples/build.py

# Test with DummyVM (each test in a separate run)
cd vmbindings/dummyvm
for p in nogc semispace; do
for t in $(ls src/tests/ -I mod.rs | sed -n 's/\.rs$//p'); do
cargo test --features $p -- $t;
done;
done;
2 changes: 1 addition & 1 deletion examples/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# check RUSTUP_TOOLCHAIN
if "RUSTUP_TOOLCHAIN" in os.environ:
toolchain = os.environ["RUSTUP_TOOLCHAIN"]
toolchain = "+" + os.environ["RUSTUP_TOOLCHAIN"]
else:
toolchain = "+nightly"

Expand Down
1 change: 0 additions & 1 deletion src/util/alloc/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pub fn align_allocation(
debug_assert!(!(fillalignmentgap && region.is_zero()));
debug_assert!(alignment <= MAX_ALIGNMENT);
debug_assert!(offset >= 0);
debug_assert!(region.is_aligned_to(MIN_ALIGNMENT));
debug_assert!((alignment & (MIN_ALIGNMENT - 1)) == 0);
debug_assert!((offset & (MIN_ALIGNMENT - 1) as isize) == 0);

Expand Down
3 changes: 3 additions & 0 deletions vmbindings/dummyvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ pub mod active_plan;
pub mod reference_glue;
pub mod api;

#[cfg(test)]
mod tests;

pub struct DummyVM;

impl VMBinding for DummyVM {
Expand Down
17 changes: 17 additions & 0 deletions vmbindings/dummyvm/src/tests/issue139.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use crate::api::*;
use mmtk::util::OpaquePointer;
use mmtk::Allocator;

#[test]
pub fn issue139_alloc_non_multiple_of_min_alignment() {
gc_init(200*1024*1024);
let handle = bind_mutator(OpaquePointer::UNINITIALIZED);

// Allocate 6 bytes with 8 bytes ailgnment required
let addr = alloc(handle, 6, 8, 0, Allocator::Default);
assert!(addr.is_aligned_to(8));
// After the allocation, the cursor is not MIN_ALIGNMENT aligned. If we have the assertion in the next allocation to check if the cursor is aligned to MIN_ALIGNMENT, it fails.
// We have to remove that assertion.
let addr2 = alloc(handle, 6, 8, 0, Allocator::Default);
assert!(addr2.is_aligned_to(8));
}
4 changes: 4 additions & 0 deletions vmbindings/dummyvm/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Each module should only contain one #[test] function.
// We should run each module in a separate test process, as we do not have proper
// setup/teardown procedure for MMTk instances.
mod issue139;

0 comments on commit 5512189

Please sign in to comment.