A bug that doesn’t exist on x86: Exploiting an ARM-only race condition

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • how-to-exploit-a-double-free

    How to exploit a double free vulnerability in 2021. Use After Free for Dummies

  • I spent some time trying to figure out why the lock-free read/write implementation is correct under x86, assuming a multiprocessor environment.

    My read of the situation was that there's already potential for a double-read / double-write between when the spinlock returns and when the head/tail index is updated.

    Turns out that I was missing something: there's only one producer thread, and only one consumer thread. If there were multiple of either, then this code would be more fundamentally broken.

    That said: IMO the use of `new` in modern C++ (as is the case in the writer queue) is often a code smell, especially when std::make_unique would work just as well. Using a unique_ptr would obviate the first concern [0] about the copy constructor not being deleted.

    One other comment: the explanation in [1] is slightly incorrect:

    > we receive back Result* pointers from the results queue rq, then wrap them in a std::unique_ptr and jam them into a vector.

    We actually receive unique_ptrs from the results queue, then because, um, reasons (probably that we forgot that we made this a unique_ptr), we're wrapping them in another unique_ptr, which works because we're passing a temporary (well, prvalue in C++17) to unique_ptr's constructor -- while that looks like it might invoke the deleted copy-constructor, it's actually an instance of guaranteed copy elision. Also a bit weird to see, but not an issue of correctness.

    (If we used unique_ptr consistently here, we might fix the scary platform-dependent leak in exchange for a likely segfault following a nullptr dereference.)

    [0] https://github.com/stong/how-to-exploit-a-double-free#0-inte...

    [1] https://github.com/stong/how-to-exploit-a-double-free#2-rece...

  • loom

    Concurrency permutation testing tool for Rust. (by tokio-rs)

  • Rust doesn't catch memory ordering errors, which can result in behavioral bugs in safe Rust and data races and memory unsafety in unsafe Rust. But Loom is an excellent tool for catching ordering errors, though its UnsafeCell API differs from std's (and worse yet, some people report Loom returns false positives/negatives in some cases: https://github.com/tokio-rs/loom/issues/180, possibly https://github.com/tokio-rs/loom/issues/166).

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • triple-buffer

    Implementation of triple buffering in Rust

  • bbqueue

    A SPSC, lockless, no_std, thread safe, queue, based on BipBuffers

  • I particularly like lock-free (wait-free?) SPSC queues because they're (relatively) easy to get right, and are extremely useful for buffering in embedded systems. I end up with something like this on almost every project:

    One side of the queue is a peripheral like a serial port that needs to be fed/drained like clockwork to avoid losing data or glitching (e.g. via interrupts or DMA), and the other side is usually software running on the main thread, that wants to be able to work at its own pace and also go to sleep sometimes.

    An SPSC queue fits this use-case nicely. James Munns has a fancy one written in Rust [1], and I have a ~100 line C template [2].

    [1] https://github.com/jamesmunns/bbqueue

    [2] https://gist.github.com/ohazi/40746a16c7fea4593bd0b664638d70...

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • A lock-free single element generic queue

    1 project | /r/C_Programming | 24 Mar 2023
  • Hyperbridge: Fast multi-producer, multi-consumer unbounded channel in Rust

    4 projects | news.ycombinator.com | 9 Feb 2024
  • SQLite: Wal2 Mode

    1 project | news.ycombinator.com | 15 Jan 2024
  • Where can I read about how to write a safe API for unsafe code?

    3 projects | /r/rust | 16 Sep 2023
  • Learning Async Rust with Too Many Web Servers

    4 projects | news.ycombinator.com | 18 Aug 2023