Earlier quoted context omitted.
Is there any vendor of actually good email-as-a-service? O365/Exchange/Outlook/Hotmail is a mess. Google has a support problem. Fastmail has an offline email problem. iCloud is not obviously suitable for professional use. What’s left?
There are multiple providers out there that have their own stacks (Google, Microsoft, Tutanota, Protonmail to some extent and others) and there are those that use more common combinations (basically just managed mail-in-a-box). Nothing perfect though, so pick your poison. Some issues are also due to the ecosystem itself. Avoiding POP3 goes a long way for example.
Bug in reader/writer locks in Windows API
91–100 of 142 posts
Re: Bug in reader/writer locks in Windows API
#92Earlier quoted context omitted.
If you have many readers and a single writer there's no point in the readers blocking each other.
True, but in my experience the overhead of std::shared_mutex outweighs the benefits. Other approaches include: * breaking up the lock so different threads can access different parts of your data structure concurrently. * double-buffering (also called ping-pong buffers) where you effectively keep two copies of your data structure. The readers can access one without blocking, a single writer can modify the other and th…
T1: writer populates copy1
T2: readers access copy1
T3: writer populates copy2, and swaps
T4: writer populates copy1, and swaps
At T4 a reader from T2 could still be accessing the old data structure.Unless I'm overthinking it.
Re: Bug in reader/writer locks in Windows API
#93I 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 "…
Re: Bug in reader/writer locks in Windows API
#94Subtle 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,…
SRWLock seems like a situation where it's small enough for you to construct proofs that what you did is correct, and important enough that the enormous expense of such proof is justified. The C++ std::mutex provided in Microsoft's STL is ludicrously big, whereas SRWLocks are the same size as a pointer. In one sense being ludicrously big is great - less risk the std::mutex will mistakenly share a cache line with your…
Re: Bug in reader/writer locks in Windows API
#95I'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?
http://www.malsmith.net/blog/patching-closed-software/
Note: not my blog. (Edit: removed a probably unnecessary, and likely inaccurate, detail).
Patching the kernel would involve a similar (but slightly more complicated) process.
Re: Bug in reader/writer locks in Windows API
#96Earlier quoted context omitted.
How did you patch the kernel? Like how is that possible?
With a hex editor, debugger, and skills that most developers these days seem to lack. I patched the kernel in memory first, using a kernel debugger, to verify my fix worked before editing the file on disk.
Re: Bug in reader/writer locks in Windows API
#97I understand why this is the case but it’s also extremely frustrating: > 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 filed OS-49268777 "SRWLOCK can deadlock after an exclusive owner has released ownership and several reader threads are attempting to acquire shared o…
Nice to know that it's not just Apple to whom reporting bugs in hopeless. :)
My literal job for the last part of my time at AWS was "help triage bugs in the AWS SDK." This is by far the best repro I've ever seen for such an in-depth event.
Most of the tickets you get in open ticket trackers are incomplete [ https://github.com/boto/boto3/issues/4011 ] nonsensical [ https://github.com/boto/boto3/issues/4018 ] or weird [ https://github.com/boto/boto3/issues/358 ].
Re: Bug in reader/writer locks in Windows API
#98Earlier quoted context omitted.
True, but in my experience the overhead of std::shared_mutex outweighs the benefits. Other approaches include: * breaking up the lock so different threads can access different parts of your data structure concurrently. * double-buffering (also called ping-pong buffers) where you effectively keep two copies of your data structure. The readers can access one without blocking, a single writer can modify the other and th…
The problem with double-buffering is that you still need to know when all the readers are no longer using one of the copies. T1: writer populates copy1 T2: readers access copy1 T3: writer populates copy2, and swaps T4: writer populates copy1, and swaps At T4 a reader from T2 could still be accessing the old data structure. Unless I'm overthinking it.
Re: Bug in reader/writer locks in Windows API
#99Earlier quoted context omitted.
True, but in my experience the overhead of std::shared_mutex outweighs the benefits. Other approaches include: * breaking up the lock so different threads can access different parts of your data structure concurrently. * double-buffering (also called ping-pong buffers) where you effectively keep two copies of your data structure. The readers can access one without blocking, a single writer can modify the other and th…
The problem with double-buffering is that you still need to know when all the readers are no longer using one of the copies. T1: writer populates copy1 T2: readers access copy1 T3: writer populates copy2, and swaps T4: writer populates copy1, and swaps At T4 a reader from T2 could still be accessing the old data structure. Unless I'm overthinking it.
Re: Bug in reader/writer locks in Windows API
#100Earlier quoted context omitted.
Based on the Windows CreateThread API [1], it doesn't say anything about memory synchronization guarantee. Does it do internally? [1] https://learn.microsoft.com/en-us/windows/win32/api/processt...
That MSDN documentation is unfortunately silent on this, but the example in the documentation (at https://learn.microsoft.com/en-us/windows/win32/procthread/c... ) only makes sense if the operating system guarantees the ordering. The C++ standard (at least a draft of it I found on a quick web search) is more explicit: it says ( https://eel.is/c++draft/thread.thread.constr ) "The completion of the invocation of the co…
> An object whose identifier is declared with no linkage and without the storage-class specifier static has automatic storage duration, as do some compound literals. The result of attempting to indirectly access an object with automatic storage duration from a thread other than the one with which the object is associated is implementation-defined
(I bet in practice almost all implementations behave as an equivalent C++ would, as per your notes, so only the ordering is relevant. But people maintaining C implementations have on occasion shown themselves to be their users' enemies, so don't quote me on this!)