Giter VIP home page Giter VIP logo

Comments (7)

myrrlyn avatar myrrlyn commented on June 7, 2024

That's a really interesting cutoff number; I wonder what's up with that.

Anyway, it's my bug and I know exactly why it happened. Can you check if current master, commit c5587f0, fixes it?

from bitvec.

kulp avatar kulp commented on June 7, 2024

That commit does not appear to have resolved the issue :

$ cargo test
  Downloaded funty v1.0.1
   Compiling funty v1.0.1
   Compiling bitvec v0.18.0 (https://github.com/myrrlyn/bitvec.git#c5587f0c)
   Compiling debug_bitbox v0.1.0 (/Users/kulp/Documents/Code/Rust/debug_bitbox)
    Finished test [unoptimized + debuginfo] target(s) in 18.34s
     Running target/debug/deps/debug_bitbox-f5adc7e290da82aa

running 1 test
debug_bitbox-f5adc7e290da82aa(80083,0x7000068bf000) malloc: *** error for object 0x7fdfb2800000: pointer being freed was not allocated
debug_bitbox-f5adc7e290da82aa(80083,0x7000068bf000) malloc: *** set a breakpoint in malloc_error_break to debug
error: test failed, to rerun pass '--lib'

Caused by:
  process didn't exit successfully: `/Users/kulp/Documents/Code/Rust/debug_bitbox/target/debug/deps/debug_bitbox-f5adc7e290da82aa` (signal: 6, SIGABRT: process abort signal)

from bitvec.

myrrlyn avatar myrrlyn commented on June 7, 2024

Neat. I really wish I knew how to run ASAN, or to have a way to be sure I understand what the Vec -> Box<[]> path looks like. Anyway, if this commit doesn't fix it, I'm out of ideas personally and will have to ask someone more familiar with the allocator.

from bitvec.

kulp avatar kulp commented on June 7, 2024

From a sample size of one, I declare the problem wholly eliminated :

$ cargo test
   Compiling bitvec v0.18.0 (https://github.com/myrrlyn/bitvec.git#3ffe9510)
   Compiling debug_bitbox v0.1.0 (/Users/kulp/Documents/Code/Rust/debug_bitbox)
    Finished test [unoptimized + debuginfo] target(s) in 13.15s
     Running target/debug/deps/debug_bitbox-f5adc7e290da82aa

running 1 test
test debug_bitbox ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

   Doc-tests debug_bitbox

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Is there a short version of why you think this works, or at least why the old code was wrong ?

Thank you. I would close the issue, but perhaps you have your own process to follow.

from bitvec.

myrrlyn avatar myrrlyn commented on June 7, 2024

At first, I thought that my construction of a Vec in BitBox::drop was incorrect, because a zero-length Vec probably frees its allocation during Vec::into_boxed_slice, and I thought maybe a zero-length boxed slice was causing a double-free. When that commit didn't fix it, I realized that such a double-free would have been spotted way before now.

The second commit addresses a different fault: the allocator is not required to preserve the address when shrinking an allocation! The macOS allocator probably has an inclusive limit at 8064 words for its bucket size; the 8065-word vector, when shrinking, was moved to a smaller allocation and the large allocation was released back to the OS.

Line 655 used the original address, not the result of Vec::into_boxed_slice.

If you unwind a commit, I bet attempting to manipulate the BitBox will get you a use-after-free violation.

I'll close this when I release the 0.17.4 hotfix in about half an hour.

Thank you for the report and the investigation!

from bitvec.

kulp avatar kulp commented on June 7, 2024

My current lack of nomicon-level Rust knowledge prevents me from completely assimilating the details of your explanation, but it remains plausible and soothing. Thanks for the quick turn-around.

from bitvec.

kulp avatar kulp commented on June 7, 2024

I learned how to run Miri, and ran it on 0.17.3 out of interest. For me, Miri finds the problem only if at least 65 bits are reserved (probably because u64 is the underlying BitStore), but that is better than 8065.

More significantly, though, Miri finds the issue on my Linux virtual machine as well, where the issue had not previously manifested. Perhaps Miri could prove useful for vetting the whole of bitvec.

from bitvec.

Related Issues (20)

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.