Giter VIP home page Giter VIP logo

thincollections's Introduction

thincollections

Latest version Documentation Minimum rustc version

Alternative implementations for vector, map and set that are faster/smaller for some use cases. ThinMap can be 2x to 5x faster than std::collections::HashMap. See the benchmarks.

Usage

Add this to your Cargo.toml:

[dependencies]
thincollections = "0.5"

and this to your crate root:

#[macro_use]
extern crate thincollections;

Rust Version Support

The minimum supported Rust version is 1.28 due to use of allocator api and NonZero*.

thincollections's People

Contributors

mohrezaei avatar ajeetdsouza avatar

Stargazers

Ian Butler avatar Kevin Xiang Li avatar  avatar Eduardo Stuart avatar Sʜɪᴍᴜʀᴀ Yū avatar CossonLeo avatar Hung-I Wang avatar Andrey Kirichenko avatar BenTheDev avatar Orhun Parmaksız avatar Sven avatar Ashish Myles avatar Karolin Varner avatar Donald Raab avatar  avatar

Watchers

 avatar

Forkers

moocow9m

thincollections's Issues

Segmentation fault cloning an empty ThinVec

I encountered a segfault trying to initialize with vec![thinvec![]; N], which I managed to reproduce with a simple clone. In debug mode this runs fine, but it fails with optimizations on.

extern crate thincollections;

use thincollections::thin_vec::ThinVec;

fn main() {
    let v = ThinVec::<usize>::new();
    let _v = v.clone();
}

I added [profile.release] debug = true and gathered crash details with GDB:

Program received signal SIGSEGV, Segmentation fault.
<thincollections::thin_vec::ThinVec<T> as core::ops::deref::Deref>::deref (self=<optimized out>)
    at /home/jistone/.cargo/registry/src/github.com-1ecc6299db9ec823/thincollections-0.5.1/src/thin_vec.rs:1709
1709                    len = *len_ptr;
Missing separate debuginfos, use: dnf debuginfo-install libgcc-8.2.1-4.fc28.x86_64
(gdb) p len_ptr
$1 = (usize *) 0xffffffffffffffff
(gdb) bt
#0  <thincollections::thin_vec::ThinVec<T> as core::ops::deref::Deref>::deref (self=<optimized out>)
    at /home/jistone/.cargo/registry/src/github.com-1ecc6299db9ec823/thincollections-0.5.1/src/thin_vec.rs:1709
#1  <thincollections::thin_vec::ThinVec<T> as core::clone::Clone>::clone (self=0x7fffffffd178)
    at /home/jistone/.cargo/registry/src/github.com-1ecc6299db9ec823/thincollections-0.5.1/src/thin_vec.rs:2327
#2  0x000055555555a45e in thin::main () at src/main.rs:7
$ rustc -Vv
rustc 1.30.0 (da5f414c2 2018-10-24)
binary: rustc
commit-hash: da5f414c2c0bfe5198934493f04c676e2b23ff2e
commit-date: 2018-10-24
host: x86_64-unknown-linux-gnu
release: 1.30.0
LLVM version: 8.0

Appending an empty ThinVec causes segfault.

Tested with [email protected] .

extern crate thincollections;
use thincollections::thinvec;

fn main() {
  let mut a = thinvec![1];
  let mut b = thinvec![];
  a.append(&mut b);
}
lldb target/debug/thinvec
(lldb) target create "target/debug/thinvec"
Current executable set to 'target/debug/thinvec' (x86_64).
(lldb) run
Process 36902 launched: '/Users/Ron/thinvec/target/debug/thinvec' (x86_64)
Process 36902 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xffffffffffffffff)
    frame #0: 0x0000000100002037 thinvec`_$LT$thincollections..thin_vec..ThinVec$LT$T$GT$$GT$::append::h03601423c7a8cc57(self=0x00007ffeefbff6a0, other=0x00007ffeefbff6b8) at thin_vec.rs:1111
   1108	        unsafe {
   1109	            self.append_elements(other.as_slice() as _);
   1110	            let len_ptr = other.u.get() as *mut usize;
-> 1111	            *len_ptr = 0;
   1112	        }
   1113	    }
   1114
Target 0: (thinvec) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xffffffffffffffff)
  * frame #0: 0x0000000100002037 thinvec`_$LT$thincollections..thin_vec..ThinVec$LT$T$GT$$GT$::append::h03601423c7a8cc57(self=0x00007ffeefbff6a0, other=0x00007ffeefbff6b8) at thin_vec.rs:1111
    frame #1: 0x0000000100002df9 thinvec`thinvec::main::h80f25aa9a59242c8 at main.rs:7
    frame #2: 0x0000000100000ed2 thinvec`std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h3004671de9d98f0c at rt.rs:74
    frame #3: 0x000000010000fe98 thinvec`std::panicking::try::do_call::hcfe6ac53944e0624 [inlined] std::rt::lang_start_internal::_$u7b$$u7b$closure$u7d$$u7d$::hf8f54988cfbc241e at rt.rs:59 [opt]
    frame #4: 0x000000010000fe8c thinvec`std::panicking::try::do_call::hcfe6ac53944e0624 at panicking.rs:310 [opt]
    frame #5: 0x000000010001c61f thinvec`__rust_maybe_catch_panic at lib.rs:103 [opt]
    frame #6: 0x000000010000bd4d thinvec`std::rt::lang_start_internal::hb972e1f76be57958 [inlined] std::panicking::try::h9432f7e8ae11f605 at panicking.rs:289 [opt]
    frame #7: 0x000000010000bd1a thinvec`std::rt::lang_start_internal::hb972e1f76be57958 [inlined] std::panic::catch_unwind::haeea9805caae6d4d at panic.rs:392 [opt]
    frame #8: 0x000000010000bd1a thinvec`std::rt::lang_start_internal::hb972e1f76be57958 at rt.rs:58 [opt]
    frame #9: 0x0000000100000eb2 thinvec`std::rt::lang_start::h9fe92eb28ef6e37d(main=(thinvec`thinvec::main::h80f25aa9a59242c8 at main.rs:4), argc=1, argv=0x00007ffeefbff880) at rt.rs:74
    frame #10: 0x0000000100002e82 thinvec`main + 34
    frame #11: 0x00007fff68cb0085 libdyld.dylib`start + 1
(lldb)
rustc -Vv
rustc 1.30.0 (da5f414c2 2018-10-24)
binary: rustc
commit-hash: da5f414c2c0bfe5198934493f04c676e2b23ff2e
commit-date: 2018-10-24
host: x86_64-apple-darwin
release: 1.30.0
LLVM version: 8.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.