archer
archer copied to clipboard
[BUG] to_string does not work inside omp parallel
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
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.
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?
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++.
OK. Thank you.
@simoatze: should this limitation be documented somewhere? In particular, how do can disable the static analysis?
@dongahn I was thinking to add an option in the archer drivers to disable the static analysis
yeah, that be great.