1.83K subscribers
3.3K photos
132 videos
15 files
3.58K links
Блог со звёздочкой.

Много репостов, немножко программирования.

Небольшое прикольное комьюнити: @decltype_chat_ptr_t
Автор: @insert_reference_here
Download Telegram
#prog #rust #rustlib

egui — это не только ценный мех библиотека для immediate mode GUI, которая может компилироваться в WASM, но и залипательная демка фрактальных часов.
6🔥1
СБП = Система божественных платежей
🤮1
#prog #meme

Про транзакции в #db наглядно
👎2
😁11👎1
🥰8🤔3👎2💩2
Forwarded from Мемы, машинки и дискретная математика (кола с кофе)
👍22😁10
Восхищаюсь людьми, которые работают на телефоне доверия.
👍8❤‍🔥1🔥1🥰1
надежды и мечты мы уже смыли...
😢9👍1👎1
#prog #article

Eliminating Data Races in Firefox – A Technical Report

ThreadSanitizer (TSan) is compile-time instrumentation to detect data races according to the C/C++ memory model on Linux. It is important to note that these data races are considered undefined behavior within the C/C++ specification. As such, the compiler is free to assume that data races do not happen and perform optimizations under that assumption. Detecting bugs resulting from such optimizations can be hard, and data races often have an intermittent nature due to thread scheduling.

Without a tool like ThreadSanitizer, even the most experienced developers can spend hours on locating such a bug. With ThreadSanitizer, you get a comprehensive data race report that often contains all of the information needed to fix the problem.

One important property of TSan is that, when properly deployed, the data race detection does not produce false positives
[выделено мной]. This is incredibly important for tool adoption, as developers quickly lose faith in tools that produce uncertain results.

===

The only true false positive we found so far turned out to be a rare bug in TSan and was fixed in the tool itself. However, developers claimed on various occasions that a particular report must be a false positive. In all of these cases, it turned out that TSan was indeed right and the problem was just very subtle and hard to understand. This is again confirming that we need tools like TSan to help us eliminate this class of bugs.

===

Bitfields are a handy little convenience to save space for storing lots of different small values. <...>. For the most part this works fine, but it has one nasty consequence: different pieces of data now alias. This means that accessing “neighboring” bitfields is actually accessing the same memory, and therefore a potential data race.

In practical terms, this means that if two threads are writing to two neighboring bitfields, one of the writes can get lost, as both of those writes are actually read-modify-write operations of all the bitfields:

// load all bitfields
int32_t oldVals = myVal.bitfields;
// modify just one
int32_t newVals = oldVals | 1 << fieldOffset;
// write all bitfields
myVal.bitfields = newVals;

===

We also found several instances of components which were explicitly designed to be single-threaded accidentally being used by multiple threads, such as bug 1681950

===

Overall Rust appears to be fulfilling one of its original design goals: allowing us to write more concurrent code safely. Both WebRender and Stylo are very large and pervasively multi-threaded, but have had minimal threading issues. What issues we did find were mistakes in the implementations of low-level and explicitly unsafe multithreading abstractions — and those mistakes were simple to fix.

This is in contrast to many of our C++ races, which often involved things being randomly accessed on different threads with unclear semantics, necessitating non-trivial refactorings of the code.
👍1
👎1💔1
👍16🥰3🔥2😢1💔1
👎1💔1