Static Analysis Problem Type Reference
Unsynchronized use of file system operations
The API functions that access the file system such as fopen, mkdir, and chmod are not thread-safe and therefore should not be used in a multi-threaded region. This can cause different execution results in parallel and sequential mode.
|
ID |
Code Location |
Description |
|---|---|---|
|
1 |
Call site |
The place where the unsafe function was called |
#include <stdio.h>
int main(int argc, char **argv)
{
int i;
FILE * fp;
#pragma omp parallel for lastprivate(fp)
for (i = 0; i < 6; i++) {
fp = fopen("my_file.txt", "r");
}
fclose(fp);
return 0;
}