Giter VIP home page Giter VIP logo

Comments (4)

cswindle avatar cswindle commented on May 28, 2024

I have raised an issue to cover needing to run an old nightly version of rust: rust-lang/rust#46138

from pinboard.

bossmc avatar bossmc commented on May 28, 2024

It seems this is due to the implementation of the underling crossbeam garbage collector. The collector doesn't call destructors when garbage expires. This is a deliberate design decision, though it's a little odd.

The way the crossbeam lock-free structures are implemented makes a couple of assumptions:

  • Each stored item of data will be retrieved from the structure eventually
  • Each stored item of data will only be retrieved once

This means that, for any T stored in the structure, they can assume that, when the entry is unlinked that this is the one and only time that the data will be read, so they simply ptr::read the T out of the entry to get the T back for free. The returned T will be dropped by the calling code (calling destructors) and the entry will be dropped (without calling destructors) when the garbage is collected.

In pinboard's case, the assumptions do not apply, data can be retrieved multiple times from a pinboard, and, when data is unlinked, it is not returned to the caller (in fact, this second facet doesn't really change anything, the caller could never safely drop the returned T since it doesn't know when enough epochs have passed to ensure no-one else is trying to clone() it on another thread).

Calling the destructors in the garbage collector is simple, the issue is that it will lead to double frees in the crossbeam lock-free implementations.

from pinboard.

bossmc avatar bossmc commented on May 28, 2024

I've proposed a change to crossbeam to call destructors but it's incomplete and probably needs discussion.

crossbeam-rs/crossbeam#158

from pinboard.

bossmc avatar bossmc commented on May 28, 2024

Fixed in #10 and released in v2.0.0. Note that there's a new restriction on the stored value, that it has to be 'static to ensure that no references outlive their referent while waiting for collection.

from pinboard.

Related Issues (3)

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.