Earlier quoted context omitted.
What about mutexes living in shared memory, and each process having a different address mapping?
All bets go out the window with adversarial multi-process shared memory mutexes. The other process may not even be running the same locking code.
Surelock: Deadlock-Free Mutexes for Rust
81–90 of 90 posts
Re: Surelock: Deadlock-Free Mutexes for Rust
#82Earlier quoted context omitted.
If big lock and little lock are at different levels you won’t have a key at the appropriate level to create an inversion by trying to acquire in the first place. T2 might “spin” waiting for small lock but assuming small lock is released at some point you’ve not got a deadlock (and by construction it’s impossible for small lock to have it’s release blocked on the acquisition of a lock that depends on big_lock). That’s…
This reply is word salad that completely fails to engage with anything I've actually said to you... please don't waste my time with more LLM generated comments.
I’ve tried to illuminate your ignorance for you but unfortunately I can’t do your thinking for you.
What I can do is recommend you try to write out the scenario you believe can create a deadlock and maybe then you’ll understand why it’s not possible and maybe my words will make a little bit more sense. If alternatively you succeed you can open an issue on the author’s open source library and create a blog post explaining their mistake. But until then you’re just unhappy you don’t understand and aren’t doing any being willful to remain uninformed.
Re: Surelock: Deadlock-Free Mutexes for Rust
#83I 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.
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 throug…
(Speaking from the perspective of someone who simultaneously loves high-performance compute and agentic AI haha)
Re: Surelock: Deadlock-Free Mutexes for Rust
#84I'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 embe…
Why? You have java.util.concurrent; you should never see a deadlock. You might see a performance degradation or maybe even livelock, but that's very, very, very rare.
What abjectly idiotic thing is in your Java codebase such that you have deadlocks?
Re: Surelock: Deadlock-Free Mutexes for Rust
#85Earlier quoted context omitted.
> unbounded TM is likely a fool’s errand It's the whole language, not just the TM code. Other languages have no way of opting out of the TM code, whereas Haskell does.
I think it is pretty sad how there are so many modern programming languages coming out that fail to actually do something novel. The primary advantage of a new programming language is that there is no legacy code to be compatible with. The software ergonomics space has been thoroughly explored, but restricting programs to subsets with useful properties is still an untapped field. It's seen that way because profession…
Depends a lot on what you are doing. Clojure and Scala were new languages, but they had a lot of legacy code to stay compatible with. C++ falls in a similar camp.
Re: Surelock: Deadlock-Free Mutexes for Rust
#86Earlier quoted context omitted.
No, the entire point of what I was saying is that big_lock and little_lock are at two different levels.
If big lock and little lock are at different levels you won’t have a key at the appropriate level to create an inversion by trying to acquire in the first place. T2 might “spin” waiting for small lock but assuming small lock is released at some point you’ve not got a deadlock (and by construction it’s impossible for small lock to have it’s release blocked on the acquisition of a lock that depends on big_lock). That’s…
T2 sits there waiting for small_lock to be available while holding big_lock for a long time.
This bit:
> ...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.
Which of course leads to conversations like can big_lock be an RWLock, ArcSwap or such.
Re: Surelock: Deadlock-Free Mutexes for Rust
#87I can't understand why address instability is a problem: if a Mutex is moved, then it can't be locked (because you need to hold a borrow while locked, which impedes moving), so using addresses is perfectly fine and there is absolutely no need to use IDs. Also the fact that it doesn't detect locking the same mutex twice makes no sense: a static order obviously detects that and when locking multiple mutexes at the same…
This was prevented on Apr 6:
https://codeberg.org/expede/surelock/commit/4f86b1ea58c7d19a...
Re: Surelock: Deadlock-Free Mutexes for Rust
#88Most of the deadlocks I've faced are with different proccesses/devices both waiting on reads from each end of a socket/uart/etc. I've taken to putting timeouts on read calls, though then you have to deal with legitimate long request cycles timing out.
Re: Surelock: Deadlock-Free Mutexes for Rust
#89Earlier quoted context omitted.
If big lock and little lock are at different levels you won’t have a key at the appropriate level to create an inversion by trying to acquire in the first place. T2 might “spin” waiting for small lock but assuming small lock is released at some point you’ve not got a deadlock (and by construction it’s impossible for small lock to have it’s release blocked on the acquisition of a lock that depends on big_lock). That’s…
I think what they're trying to say is that sure it's deadlock-free but it might be sacrificing performance. T2 sits there waiting for small_lock to be available while holding big_lock for a long time. This bit: > ...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. Which of course leads to conversa…
> Which of course leads to conversations like can big_lock be an RWLock, ArcSwap or such.
I’m not sure what you’re trying to say. This blog post is about a mutex type that is guaranteed to not dead lock.
And again, OP is horribly wrong on the terminology - there’s no spinning in any sane system. You ask the kernel to acquire the mutex for you if you fail and the kernel just puts your thread to sleep until the lock can be acquired. So all threads are guaranteed to be making forward progress. The ideal granularity of the locks themselves is completely irrelevant - that’s a domain-specific decision.
Re: Surelock: Deadlock-Free Mutexes for Rust
#90Earlier quoted context omitted.
Don't address introduce ambiguous locking order across attempts? While not obviously problematic, that seems weird enough you would need to validate that it is explicitly safe.
If I need to grab 100 locks, they are all moving around a lot, but I've got the first 10, will the order be the same for someome trying to get the same 100? Eg maybe someone swaps two that neither of us has grabbed yet.