aeplay / chunky Goto Github PK
View Code? Open in Web Editor NEWAbstract storage of heterogeneously-sized entity-collections
License: MIT License
Abstract storage of heterogeneously-sized entity-collections
License: MIT License
lib.rs contains a #![feature] line for vec_resize_default, but it doesn't seem to be necessary for the crate, and removing it allows compilation on stable
Lines 29 to 41 in ef8533a
Chunk API does not respect the align requirement of types. Unaligned reference can be created with the API, which is an undefined behavior.
#![forbid(unsafe_code)]
use chunky::{HeapStorage, Ident, Value};
use std::rc::Rc;
#[repr(align(256))]
struct LargeAlign(u8);
impl Drop for LargeAlign {
fn drop(&mut self) {
println!("Dropped");
}
}
fn main() {
let ident = Ident(String::from("ident"));
let storage = Rc::new(HeapStorage);
let value = Value::load_or_default(ident, LargeAlign(0), storage.clone());
// Value reference does not have a correct alignment
let v = &*value as *const _ as usize;
println!("{:x}", v);
assert!(v % std::mem::align_of::<LargeAlign>() == 0);
// https://github.com/aeplay/chunky/blob/ef8533aec961eb5f415414dcd81ec4b395bae177/src/value.rs#L43-L49
// Another bug that is not UB: `LargeAlign::Drop` is not called due to incorrect `drop_in_place()` in `Value::drop()`.
// "Dropped" should be printed otherwise.
}
Output:
555e921bea80
thread 'main' panicked at 'assertion failed: v % std::mem::align_of::<LargeAlign>() == 0', src/main.rs:42:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Return Code: 101
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.