Questions tagged [data-race]

A data race occurs when:

  • two or more threads in a single process access the same memory location concurrently, and

  • at least one of the accesses is for writing, and

  • the threads are not using any exclusive locks to control their accesses to that memory.

When these three conditions hold, the order of accesses is non-deterministic, and the computation may give different results from run to run depending on that order. Some data-races may be benign (for example, when the memory access is used for a busy-wait), but many data-races are bugs in the program.

(source: https://docs.oracle.com/cd/E19205-01/820-0619/geojs/index.html)

108 questions
0
votes
2 answers

ARM64 64 bit load/store data race

According to this, a 64 bit load/store is considered to be an atomic access on arm64. Given this, is the following program still considered to have a data race (and thus can exhibit UB) when compiled for arm64 (ignore ordering with respect to other…
ktqq99
  • 25
  • 5
0
votes
1 answer

Why the code snippet gets stuck when optimization is enabled?

There are three question about the code snippet below. When the macro(i.e. NO_STUCK_WITH_OPTIMIZATION ) is not enabled, why this code snippet gets stuck when the optimization is enabled(i.e. -O1, -O2 or -O3) whereas the program works well if the…
John
  • 2,963
  • 11
  • 33
0
votes
0 answers

Mutex vs RWMutex and data races?

I'm pretty new in Go and need the answers to some of dilemmas while implementing small HTTP notifier than runs concurrently, sending message to the configured HTTP endpoint. For that purpose, I use the following structure: type Notifier struct { …
aldm
  • 343
  • 1
  • 11
0
votes
0 answers

Directshow Transform filter's implementation exposes data race? [solved]

I'm writing a transform filter in Directshow. I've looked at the Transform filter implementation. They use 1 filter_lock for protecting filter's state and another lock called streaming_lock for protecting resources used in streaming thread. But in…
irous
  • 401
  • 3
  • 8
0
votes
1 answer

Why does sanitizer give warnings when processing asynchronous boost::asio operations in parallel in my code?

I am decided to test my project written using boost::asio (I run io_service::run in different threads) with all kinds of sanitizers and on thread-sanitizer got data race, namely it reported that socket is at the same time checked for is_open…
0
votes
1 answer

Data race and asyncio python

Trying to understand how asyncio works. The task: have to add some code to lower pseudocode so that requests must be consecutive (0, 1, 2... 9), I need to exclude data race. I tried to add loop (asyncio.get_event_loop() and run_until_complete()),…
Ryadas
  • 1
0
votes
0 answers

Does Rust automatically execute code using multithreads

I am reading about Rust's ownership and it turns out that Rust's ownership, reference, and borrow features focus on preventing data race via some restrictions in reference mutability. I wonder why Rust forces us to obey these restrictions? Is that…
0
votes
1 answer

Multithreaded Nagel–Schreckenberg model (traffic simulation) with OpenMP

I'm trying to write a multithreaded Nagel–Schreckenberg model simulation in c language and have some problems when a thread accesses the data which wasn't calculated yet. Here is a working code which only parallelizes velocity calculation per…
0
votes
0 answers

Data race between differenct processes using same database

I have a system which includes MySQL as database and RabbitMQ for organizing asynchronous data processing. There are two processes (in two different containers) that work with the same record. First one updates record status in db transaction and…
smiler
  • 1
0
votes
1 answer

C++11 std::threads not exiting

Could you please check the following code which is not exiting even after condition becomes false? I'm trying to print numbers from 1 to 10 by first thread, 2 to 20 by second thread likewise & I have 10 threads, whenever count reaches to 100, my…
0
votes
2 answers

Does this singleton instance implementation has a race condition?

Someone told me the memCacheInstance has race condition, but go run -race could not tell. Codes: type MemCache struct { data []string } var memCacheInstance *MemCache var memCacheCreateMutex sync.Mutex func GetMemCache() *MemCache { if…
Andrew Cui
  • 1,269
  • 2
  • 11
  • 10
0
votes
2 answers

C++ mutex doesn't work - synchronization fails

I would like to apply as simple mutex as possible. #include #include #include #include #include #include using namespace std; int sum; static mutex m; void addValue(int value) { …
BartekS
  • 127
  • 1
  • 1
  • 7
0
votes
1 answer

Data race difference with Pointer Recevier and Non Pointer Recevier

I found a data race during testing with -race flag. The data race happened on when updating a struct and read value from the struct method. Later I found to change the method from non-pointer receiver to a pointer receiver can solve the data race.…
vreal
  • 797
  • 1
  • 7
  • 16
0
votes
1 answer

Can 'data race' happen with triggers in MariaDB with InnoDB?

My application processes very large volume of real-time data (>200 million a day) and I need to aggregate them real time in order keep reporting performant. The data is fed and hence processed randomly by several threads by the server. I use MariaDB…
ben
  • 122
  • 9
0
votes
3 answers

Is write guaranteed with one thread writing and another reading non-atomic

Say I have bool unsafeBool = false; int main() { std::thread reader = std::thread([](){ std::this_thread::sleep_for(1ns); if(unsafeBool) std::cout << "unsafe bool is true" << std::endl; }); std::thread…
A.Hristov
  • 481
  • 1
  • 4
  • 13