Issue Details (XML | Word | Printable)

Key: STDCXX-467
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Martin Sebor
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
C++ Standard Library

[Intel Thread Checker 3.1] bogus data race after pthread_once()

Created: 03/Jul/07 09:37 PM   Updated: 17/Aug/07 12:44 AM
Return to search
Component/s: External
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Environment: Intel Thread Checker 3.1 with Intel C++ 9.1.049 on Red Hat Enterprise Linux AS release 4 (Nahant Update 4)
Issue Links:
Dependants
 


 Description  « Hide
Running the program below through the thread checker gives the Wrtite->Read data race error shown in the output:

$ cat t.c && icc -V t.c -pthread && tcheck_cl -v a.out
#include <pthread.h>

static int flag;
static void init () { flag = 1; }

static pthread_once_t flag_init;
static int foo () {
pthread_once (&flag_init, init);
return flag;
}

static void* thr_func (void *a) {
int i;
int n = 0;
for (i = 0; i != 100; ++i)
n += foo ();

return (void*)n;
}

int main () {
pthread_t pid [2];
int i;

for (i = 0; i != sizeof pid / sizeof *pid; ++i)
pthread_create (pid + i, 0, thr_func, 0);

for (i = 0; i != sizeof pid / sizeof *pid; ++i)
pthread_join (pid [i], 0);
}
Intel(R) C Compiler for Intel(R) EM64T-based applications, Version 9.1 Build 20070320 Package ID: l_cc_c_9.1.049
Copyright (C) 1985-2007 Intel Corporation. All rights reserved.

Edison Design Group C/C++ Front End, version 3.6 (Mar 22 2007 02:18:08)
Copyright 1988-2005 Edison Design Group, Inc.

GNU ld version 2.15.92.0.2 20040927
Intel(R) Thread Checker 3.1 command line instrumentation driver (24400)
Copyright (c) 2007 Intel Corporation. All rights reserved.
Building project
Instrumenting
14% a.out ( All Functions ):..

Running: /build/sebor/stdcxx-icc-9.1_049-15S/tests/a.out

Application finished

_______________________________________________________________________________

ID Short Des Sever Co Contex Description 1st Ac 2nd Acc
  cription ity un t[Best   cess[B ess[Bes
    Name t ]   est] t]

_______________________________________________________________________________

1 Write -> Error 10 [a.out Memory read at [a.out, 0x7b9] [a.out [a.out,
  Read   0 , conflicts with a prior memory , 0x7b9]
  data-race     0x79a] write at [a.out, 0x7d0] (flow 0x7d0]  
          dependence)    

_______________________________________________________________________________

2 Thread te Infor 1 WholeP Thread termination at [a.out, [a.out [a.out,
  rmination matio   rogram 0x762] - includes stack , 0x762]
    n   1 allocation of 10.004 MB and use 0x762]  
          of 5.047 KB    

_______________________________________________________________________________

3 Thread te Infor 1 WholeP Thread termination at [a.out, [a.out [a.out,
  rmination matio   rogram 0x762] - includes stack , 0x762]
    n   2 allocation of 10.004 MB and use 0x762]  
          of 4.984 KB    

_______________________________________________________________________________

4 Thread te Infor 1 WholeP Thread termination at [a.out, [a.out [a.out,
  rmination matio   rogram 0x728] - includes stack , 0x728]
    n   3 allocation of 10 MB and use of 0x728]  
          1.984 KB    

_______________________________________________________________________________



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Martin Sebor made changes - 17/Aug/07 12:44 AM
Field Original Value New Value
Link This issue blocks STDCXX-523 [ STDCXX-523 ]