- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would like to report a false positive in the Intel Pointer Checker.
When using atomic pointers, the bounds metadata is not updated atomically with the pointer itself causing a race and a false report in the Checker. My conclusion: Intel Pointer Checker (or future MPX-based tools) can not be used with atomic pointers. Am I wrong? Please comment.
Using composer_xe_2013.5.192 on Linux.
% cat cxx11_ptr_check.cc
[cpp]
#include <atomic>
#include <thread>
#include <iostream>
#include <assert.h>
std::atomic<int *> p;
int A, B;
void Thread1() { for (int i = 0; i < 100000; i++) p = &A; }
void Thread2() { for (int i = 0; i < 100000; i++) p = &B; }
void Thread3() { for (int i = 0; i < 100000; i++) assert(*p == 0); }
int main() {
std::cout << "A=" << &A << " B=" << &B << std::endl;
std::thread t1(Thread1);
std::thread t2(Thread2);
std::thread t3(Thread3);
t1.join();
t2.join();
t3.join();
}
[/cpp]
% icpc -g -O2 -std=c++0x -check-pointers=rw cxx11_ptr_check.cc -lpthread; ./a.out
A=0x61bc48 B=0x61bc4c
CHKP: Bounds check error
lb: 0x61bc48
ub: 0x61bc4b
addr: 0x61bc4c
end: 0x61bc4f
size: 4
Traceback:
at address 0x405289 in function _Z7Thread3v
in file /tmp/cxx11_ptr_check.cc line 9
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
add "p = &A;" between lines 10 and 11 for correctness, otherwise p may be zero when accessed.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page