Skip to content
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
6 changes: 6 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ jobs:
- uses: actions/checkout@v4
- name: uname -a
run: uname -a
- name: Install wasmtime-cli
run: cargo install --version 33.0.0 wasmtime-cli
- name: Install target wasm32-wasip2
run: rustup target add wasm32-wasip2
- name: Build and test
run: ./ci/jobs/build-and-test.sh
- name: Build and test (WASM)
run: ./ci/jobs/build-and-test-wasm.sh
rustfmt:
runs-on: ubuntu-24.04
steps:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ members = [

[package]
name = "picoalloc"
version = "2.1.0"
version = "3.0.0"
edition = "2021"
authors = ["Jan Bujak <jan@parity.io>"]
repository = "https://github.com/koute/picoalloc"
Expand All @@ -30,9 +30,8 @@ panic = "abort"

[features]
default = []
alloc = []
global_allocator_libc = []
global_allocator_rust = ["alloc"]
global_allocator_rust = []
paranoid = ["strict_provenance"]
strict_provenance = []
corevm = ["dep:polkavm-derive"]
Expand Down
16 changes: 16 additions & 0 deletions ci/jobs/build-and-test-wasm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -euo pipefail
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
cd ../..

cargo check --features paranoid,global_allocator_rust --target=wasm32-wasip2

echo ">> cargo test (debug, WASM)"
wasmtime $(cargo test --features paranoid --target=wasm32-wasip2 --no-run --message-format=json | grep -oE '"executable":"[^"]+"' | cut -d ":" -f 2 | grep -oE '[^"]+')

echo ">> cargo test (release, WASM)"
wasmtime $(cargo test --features paranoid --release --target=wasm32-wasip2 --no-run --message-format=json | grep -oE '"executable":"[^"]+"' | cut -d ":" -f 2 | grep -oE '[^"]+')

echo ">> cargo test (debug, global allocator, WASM)"
wasmtime $(cargo test --features paranoid,global_allocator_rust --target=wasm32-wasip2 --no-run --message-format=json | grep -oE '"executable":"[^"]+"' | cut -d ":" -f 2 | grep -oE '[^"]+')
3 changes: 3 additions & 0 deletions ci/jobs/build-and-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ cargo test --all --release
echo ">> cargo test (paranoid)"
cargo test --features paranoid

echo ">> cargo test (paranoid, global allocator)"
cargo test --features paranoid,global_allocator_rust

echo ">> cargo build (native)"
cargo build -p picoalloc_native --release

Expand Down
1 change: 1 addition & 0 deletions ci/run-all-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
cd ..

./ci/jobs/build-and-test.sh
./ci/jobs/build-and-test-wasm.sh

case "$OSTYPE" in
linux*)
Expand Down
2 changes: 1 addition & 1 deletion fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions fuzz/fuzz_targets/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ enum Op {
Free { index: usize },
}

use picoalloc::{Allocator, System, Size};
use picoalloc::{Allocator, Size, UnsafeSystem};

fn fill_slice(seed: u128, slice: &mut [u8]) {
let mut rng = oorandom::Rand64::new(seed);
Expand All @@ -27,7 +27,7 @@ fn fill_slice(seed: u128, slice: &mut [u8]) {
}

fuzz_target!(|ops: Vec<Op>| {
let mut allocator = Allocator::new(System, Size::from_bytes_usize(32 * 1024 * 1024).unwrap());
let mut allocator = Allocator::new(UnsafeSystem, Size::from_bytes_usize(32 * 1024 * 1024).unwrap());
let mut allocations: Vec<(*mut u8, Vec<u8>)> = vec![];
let mut alive_addresses = BTreeSet::new();

Expand All @@ -42,7 +42,7 @@ fuzz_target!(|ops: Vec<Op>| {

assert_eq!(pointer.addr() % align, 0);

let usable_size = unsafe { Allocator::<System>::usable_size(pointer) };
let usable_size = unsafe { Allocator::<UnsafeSystem>::usable_size(pointer) };
assert!(usable_size >= size);

let data = {
Expand Down
Loading