PRUNERS / archer

Archer, a data race detection tool for large OpenMP applications
https://pruners.github.io/archer
Apache License 2.0
61 stars 13 forks source link

[BUG] to_string does not work inside omp parallel #43

Open planetA opened 7 years ago

planetA commented 7 years ago

Hi,

here is a minimal example

#include <iostream>
#include <string>

int main()
{
  int a = 2222;
#pragma omp parallel for
  for (int i = 0; i < 10000; i++) {
    std::cout << a << std::endl;
    std::cout << std::to_string(a) << std::endl;
  }
}

without archer it prints 2222 all the time with archer to_string prints 4986765

Version:

clang version 3.9.1 (tags/RELEASE_391/final) Target: x86_64-unknown-linux-gnu

simoatze commented 7 years ago

Hi,

thanks for reporting this problem. This is actually a known problem, our static analysis pass does not work well with C++ code, especially with third-party library (such as the std lib).

As a temporary fix you can run archer without static analysis just removing this string -Xclang -load -Xclang /your/path/LLVMArcher.so from clang-archer and clang-archer++ commands.

planetA commented 7 years ago

I replaced to_string with snprintf, so this kind of solved the problem. But I suspect that archer may miss some race conditions, because I get non-deterministic result in my program when I shouldn't. Would you advise me not to use C++ with archer at all?

simoatze commented 7 years ago

As I said, Archer static analysis phase has troubles with C++, if you remove the pass from the archer commands it would only apply the dynamic analysis at runtime and everything should work fine even with C++.

planetA commented 7 years ago

OK. Thank you.

dongahn commented 7 years ago

@simoatze: should this limitation be documented somewhere? In particular, how do can disable the static analysis?

simoatze commented 7 years ago

@dongahn I was thinking to add an option in the archer drivers to disable the static analysis

dongahn commented 7 years ago

yeah, that be great.