Live data from Hacker News

Bug in reader/writer locks in Windows API

old.reddit.com

51–60 of 142 posts

Re: Bug in reader/writer locks in Windows API

#51

Earlier quoted context omitted.

So it doesn't use a shared lock when .read() is used?

Rust has both Mutex and RWLock. The Mutex only uses exclusive locks, there's no distinction between "read" and "write".

Oh sorry my morning brain thought the comment was all about RWLock

Re: Bug in reader/writer locks in Windows API

#52

I was wondering how something so basic could go unnoticed for so long. Halfway down the page on OP's link, a user u/rbmm provides a compelling answer: that there are (possibly expected?) cases where a thread trying to acquire the lock in shared mode can accidentally get it in exclusive mode instead. This is due to interleaving of atomic bit test-and-[re]set operations between the (shared mode acquire) thread and the…

Why does it have to use bit test and set and interleave with other threads, though. AIUI you can use a CAS loop to implement any RMW atomically over word-sized (or double word sized, on many platforms) data. That seems like a no-brainer.

For comparison, the Rust implementation for lightweight RWLocks on futex-capable *nix platforms is here: https://doc.rust-lang.org/stable/src/std/sys/unix/locks/fute... It sets the "reader counter" in the underlying atomic to a special value to signal that the lock is set for exclusive access. So a reader thread acquiring the lock as shared can never result in this kind of bug. Bits are used to signal whether readers or writers are currently waiting on a lock, but this just cannot turn a lock that's acquired for shared access into exclusive, or vice versa.

Re: Bug in reader/writer locks in Windows API

#53
post #40

Earlier quoted context omitted.

I've noticed a lot of big products have a user feedback cycle that goes something like this: - Create new feedback tracker - Direct feedback to tracker - Stop paying any attention to tracker - Tracker is hundreds of pages of users shouting into the void, and much of it out-of-date - Delete everything - Create new feedback tracker...

The fundamental problem here is that they have a billion users and most of them don't know what they're talking about. If you create a simple way to contact the company it will soon be full of messages from end users who can't even articulate what their problem is but it's usually some kind of malware or user error and is definitely not a problem with whatever component they're reporting the issue against. What you r…

Microsoft makes ~16 billion $ a quarter in profit, of which they return ~10 billion $ to their investors.

They could go and spend 200 million a quarter on decent customer support without making too much of a dent in their financial line.

[1] https://www.microsoft.com/en-us/investor/earnings/fy-2023-q2...

Re: Bug in reader/writer locks in Windows API

#54
I'm curious if this also occurs in WINE's implementation.

I also want to test this on my highly customised XP install which has been patched to add the SRW API among other extensions, and where I had also patched the kernel to fix a race condition causing a deadlock in the keyed event API that the SRW implementation is based on (maybe it's this same one, although in Vista+ they changed it significantly; but the same edge case could occur.)

Re: Bug in reader/writer locks in Windows API

#55

I'm curious if this also occurs in WINE's implementation. I also want to test this on my highly customised XP install which has been patched to add the SRW API among other extensions, and where I had also patched the kernel to fix a race condition causing a deadlock in the keyed event API that the SRW implementation is based on (maybe it's this same one, although in Vista+ they changed it significantly; but the same…

How did you patch the kernel? Like how is that possible?

Re: Bug in reader/writer locks in Windows API

#56

Earlier quoted context omitted.

The fundamental problem here is that they have a billion users and most of them don't know what they're talking about. If you create a simple way to contact the company it will soon be full of messages from end users who can't even articulate what their problem is but it's usually some kind of malware or user error and is definitely not a problem with whatever component they're reporting the issue against. What you r…

Microsoft makes ~16 billion $ a quarter in profit, of which they return ~10 billion $ to their investors. They could go and spend 200 million a quarter on decent customer support without making too much of a dent in their financial line. [1] https://www.microsoft.com/en-us/investor/earnings/fy-2023-q2...

$200M is approximately $0.15/user. How much support do you expect to get for that?

Re: Bug in reader/writer locks in Windows API

#57
post #32

> It is extremely difficult for programmer-users to report bugs against the Windows API (we're supposed to direct you to Feedback Hub, but you may as well transmit your message into deep space). :'‑(

I've ran into this too, the feedback hub seems to be populated by first line support types.

I also found a bug in a win32 API and the feedback hub told me to reboot my PC

Re: Bug in reader/writer locks in Windows API

#58
post #9

Once upon a time, you could buy various things from MS that came with support incidents. I had an MSDN subscription that came with two per year. Using an incident got you an actual support engineer who would be helpful and escalate issues if necessary. And, if your issue turned out to be a real bug of any significance in an MS product, your support incident would be credited back. This was great for developers (real…

You can still pay MS for support. Whether you'll get the answer you want, as the others have noted in sibling comments, is highly variable.

Re: Bug in reader/writer locks in Windows API

#59

Subtle bugs in Reader/Writer locks do not surprise me. I worked on an in-house implementation based on Win32 (before C++11 and std::shared_mutex) and my recollection is that although the implementation sounds simple it is exceedingly easy to make subtle mistakes. The experience left me with such a bad feeling for shared locks that I tend to avoid them unless absolutely required. When I last tested std::shared_mutex,…

It has been my experience that anything related to concurrency can be full of subtle edge cases. I tend to avoid it completely unless absolutely necessary.

Re: Bug in reader/writer locks in Windows API

#60

Earlier quoted context omitted.

Microsoft makes ~16 billion $ a quarter in profit, of which they return ~10 billion $ to their investors. They could go and spend 200 million a quarter on decent customer support without making too much of a dent in their financial line. [1] https://www.microsoft.com/en-us/investor/earnings/fy-2023-q2...

$200M is approximately $0.15/user. How much support do you expect to get for that?

How many of these 1 billion users actually need support? Only a tiny fraction.
Post reply on HN