frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Surelock: Deadlock-Free Mutexes for Rust

https://notes.brooklynzelenka.com/Blog/Surelock
81•codetheweb•3d ago

Comments

eru•2h ago
I agree with the author: it's a shame that TVars aren't catching on in more languages. They are a great idea from the database world, that we could use in the rest of computing, too.
embedding-shape•1h ago
The entire programming (or even computing) ecosystem suffers from this issue where very useful ideas don't always propagate across domains even though they just make a whole lot of sense. I'm not sure if it's because they truly wouldn't work out in practice, or if it's just a discovery/communication thing.

One thing that I think do affect things, is that language design discussions tend to be concentrated into their own communities based on the programming language itself, rather than one "programming language discussions" place where everyone can easier cross-pollinate ideas across languages. Luckily, there are some individuals who move between communities without effort, which does lead to a bit of ideas making it across, but it feels like we're missing out on so much evolution and ideas from various languages across the ecosystem.

eru•1h ago
> Luckily, there are some individuals who move between communities without effort, [...]

Oh, many of these travelers spend a lot of effort!

01HNNWZ0MV43FF•54m ago
It's discovery and communication. Public education for adults is way under-appreciated in many many scopes.
twoodfin•1h ago
The canonical industrial explanation “why not” is probably this 2010 piece from Joe Duffy @ Microsoft:

http://joeduffyblog.com/2010/01/03/a-brief-retrospective-on-...

vlovich123•49m ago
I don’t think we read the same thing.

> Models can be pulled along other axes, however, such as whether memory locations must be tagged in order to be used in a transaction or not, etc. Haskell requires this tagging (via TVars) so that side-effects are evident in the type system as with any other kind of monad. We quickly settled on unbounded transactions.

Snip

> In hindsight, this was a critical decision that had far-reaching implications. And to be honest, I now frequently doubt that it was the right call. We had our hearts in the right places, and the entire industry was trekking down the same path at the same time (with the notable exception of Haskell)

So basically not that TM isn’t workable, but unbounded TM is likely a fool’s errand but Haskell’s is bounded TM that requires explicit annotation of memory that will participate in atomicity.

jandrewrogers•22m ago
The cross-fertilization of ideas across computer science domains is more limited than I think people assume. Databases are just one area that contains a lot of good ideas that never seem to leak into other parts of the software world.

Supercomputing is another domain that has deep insights into scalable systems that is famously so insular that ideas rarely cross over into mainstream scalable systems. My detour through supercomputing probably added as much to my database design knowledge as anything I actually did in databases.

cptroot•1h ago
I appreciate that this appears to be an incremental improvement on Fuschia's tree_lock, with the sharp edges sanded off. Good work! I hope I won't have to use it :p
jcalvinowens•1h ago
The Level<> abstraction is a really neat way to have your cake and eat it too: you only need a consistent arbitrary order to avoid deadlocks, but the order can have performance consequences when some locks are more coarse than others.

But the example seems backwards to me: unless every callsite that locks any item always locks the big global lock first (probably not true, because if you serialize all item access on a global lock then a per-item lock serves no purpose...), aren't you begging for priority inversions by acquiring the big global lock before you acquire the item lock?

My only gripe is missing the obvious opportunity for Ferengi memes ("rules of acquisition") :D :D

vlovich123•58m ago
There’s no global lock. There’s a linear MutexKey<N> that a lock of Level >= N has to be acquired with. Aquiring it consumes MutexKey<N> and hands you back MutexKey<Level+1> where Level is the N of the level you’re locking.

There’s no priority inversion possible because locks can only ever be held in decreasing orders of priority - you can’t acquire a low priority lock and then a high priority lock since your remaining MutexKey won’t have the right level.

jcalvinowens•30m ago
In the example it seems pretty clear to me that:

    Mutex::new(AppConfig::default());
...is meant to be acquiring a mutex protecting some global config object, yes? That's what I'm calling a "global lock".

> There’s no priority inversion possible because locks can only ever be held in decreasing orders of priority

    T1               T2
    --               --
    small_lock();
                     big_lock();
                     small_lock(); <--- Spins waiting for T1
                 
...and now any other thread that needs big_lock() spins waiting for T2 to release it, but T2 is spinning waiting for T1 to release the (presumably less critical) small lock.
airstrike•1h ago
I'd read this, but I can't stomach this ChatGPT voice. It's absolutely grating.
PaulDavisThe1st•51m ago
So tired of this sort of comment. LLMs are trained using (primarily, generally) online material. It sounds like online humans, in aggregate, plus or minus a bit of policy on the part of the model builders.
CyberDildonics•46m ago
They write like the worst possible person. It's terrible and obnoxious, there is no reason to put up with it.
Groxx•36m ago
tbh I'm not getting GPT-voice from this
ericb•6m ago
I'm not either. If this was GPT-voice, I'd be happy. It's concise, technical, with good emphasis but no drama or AI tropes.
vlovich123•1h ago
I feel like Fuschia’s DAG approach can still be made compile time lock free by either disallowing holding locks from different branches or requiring an ordering when that does happen to prevent cycles (ie you can’t acquire them independently, you have to acquire all independent branches as a single group.
0x1ceb00da•52m ago
What is the "graph" view on the right side?
Groxx•49m ago
>Why a Total Order, Not a DAG?

>This is a deliberate design decision. lock_tree uses a DAG, which lets you declare that branches A and B are independent — neither needs to come before the other. Sounds great, but it has a subtle problem: if thread 1 acquires A then B, and thread 2 acquires B then A, and both orderings are valid in the DAG, you have a deadlock that the compiler happily approved.

Would it be possible to build one at compile time? Static levels seem like they won't let you share code without level-collaboration, so that might be kinda important for larger-scale use.

I don't know enough about Rust's type system to know if that's possible though. Feels like it's pushing into "maybe" territory, like maybe not with just linear types but what about proc macros?

I can definitely see why it's easier to build this way though, and for some contexts that limitation seems entirely fine. Neat library, and nice post :)

electromech•35m ago
I'm intrigued! I was fighting deadlocks in some Java code this week, and I'm working on a Rust project to maybe replace some of that.

One thing I didn't see in the post or the repo: does this work with async code?

I couldn't find the "search" button on Codeberg, and tests/integration.rs didn't have any async.

For embedded, I have had my eye on https://github.com/embassy-rs/embassy (which has an async runtime for embedded) and would love a nice locking crate to go with it.

rowanG077•22m ago
That's pretty awesome. Dead locks are extremely tough to debug. There are even cases where I saw behavior in code that might have been a dead lock. I never found out though.

Small models also found the vulnerabilities that Mythos found

https://aisle.com/blog/ai-cybersecurity-after-mythos-the-jagged-frontier
135•dominicq•1h ago•42 comments

Advanced Mac Substitute is an API-level reimplementation of 1980s-era Mac OS

https://www.v68k.org/advanced-mac-substitute/
67•zdw•2h ago•12 comments

Cirrus Labs to join OpenAI

https://cirruslabs.org/
158•seekdeep•4h ago•81 comments

Surelock: Deadlock-Free Mutexes for Rust

https://notes.brooklynzelenka.com/Blog/Surelock
82•codetheweb•3d ago•22 comments

Phone Trips

http://www.wideweb.com/phonetrips/
14•bookofjoe•1h ago•0 comments

Filing the corners off my MacBooks

https://kentwalters.com/posts/corners/
1180•normanvalentine•19h ago•542 comments

Every plane you see in the sky – you can now follow it from the cockpit in 3D

https://flight-viz.com/cockpit.html?lat=40.64&lon=-73.78&alt=3000&hdg=220&spd=130&cs=DAL123
8•coolwulf•2d ago•6 comments

The Problem That Built an Industry

https://ajitem.com/blog/iron-core-part-1-the-problem-that-built-an-industry/
48•ShaggyHotDog•3h ago•20 comments

Keeping a Postgres Queue Healthy

https://planetscale.com/blog/keeping-a-postgres-queue-healthy
12•tanelpoder•1h ago•0 comments

Show HN: Pardonned.com – A searchable database of US Pardons

229•vidluther•11h ago•81 comments

Optimal Strategy for Connect 4

https://2swap.github.io/WeakC4/explanation/
205•marvinborner•2d ago•27 comments

Starfling: A one-tap endless orbital slingshot game in a single HTML file

https://playstarfling.com
430•iceberger2001•2d ago•110 comments

South Korea introduces universal basic mobile data access

https://www.theregister.com/2026/04/10/south_korea_data_access_universal/
163•saikatsg•4h ago•49 comments

Volunteers turn a fan's recordings of 10K concerts into an online treasure trove

https://apnews.com/article/aadam-jacobs-collection-concerts-internet-archive-chicago-b1c9c4466a2d...
267•geox•3d ago•44 comments

Cooperative Vectors Introduction

https://www.evolvebenchmark.com/blog-posts/cooperative-vectors-introduction
29•JasperBekkers•1d ago•1 comments

1D Chess

https://rowan441.github.io/1dchess/chess.html
929•burnt-resistor•1d ago•154 comments

The disturbing white paper Red Hat is trying to erase from the internet

https://www.osnews.com/story/144776/the-disturbing-white-paper-red-hat-is-trying-to-erase-from-th...
19•choult•1h ago•0 comments

Previously unknown verses by Empedocles found on papyrus

https://www.thehistoryblog.com/archives/75792
35•danielam•2d ago•6 comments

How Much Linear Memory Access Is Enough?

https://solidean.com/blog/2026/how-much-linear-memory-access-is-enough/
46•PhilipTrettner•3d ago•4 comments

The future of everything is lies, I guess – Part 5: Annoyances

https://aphyr.com/posts/415-the-future-of-everything-is-lies-i-guess-annoyances
110•aphyr•3h ago•62 comments

How Passive Radar Works

https://www.passiveradar.com/how-passive-radar-works/
110•surprisetalk•2d ago•37 comments

Installing every* Firefox extension

https://jack.cab/blog/every-firefox-extension
567•RohanAdwankar•19h ago•70 comments

Chimpanzees in Uganda locked in eight-year 'civil war', say researchers

https://www.bbc.com/news/articles/cr71lkzv49po
390•neversaydie•22h ago•235 comments

Rockstar Games Hacked, Hackers Threaten a Massive Data Leak If Not Paid Ransom

https://kotaku.com/rockstar-games-reportedly-hacked-massive-data-leak-ransom-gta-6-shinyhunters-2...
21•c420•1h ago•11 comments

AI assistance when contributing to the Linux kernel

https://github.com/torvalds/linux/blob/master/Documentation/process/coding-assistants.rst
441•hmokiguess•23h ago•323 comments

Artemis II safely splashes down

https://www.cbsnews.com/live-updates/artemis-ii-splashdown-return/
1138•areoform•17h ago•359 comments

France's government is ditching Windows for Linux, says US tech a strategic risk

https://www.xda-developers.com/frances-government-ditching-windows-for-linux/
306•pabs3•9h ago•177 comments

Bitcoin miners are losing on every coin produced as difficulty drops

https://www.coindesk.com/markets/2026/03/22/bitcoin-miners-are-losing-usd19-000-on-every-btc-prod...
141•PaulHoule•4h ago•133 comments

WireGuard makes new Windows release following Microsoft signing resolution

https://lists.zx2c4.com/pipermail/wireguard/2026-April/009561.html
524•zx2c4•1d ago•150 comments

Borges' cartographers and the tacit skill of reading LM output

https://galsapir.github.io/sparse-thoughts/2026/04/11/map-and-territory/
20•galsapir•4h ago•3 comments