Intel Pin gets segmentation fault if target application uses fopen() function?

111 views Asked by At

I'm currently using Intel Pin to trace the memory access of some applications. But I found that if the target application used fopen() function, the Pinatrace tool crashed with segmentation fault. Here is the test code I'm usingļ¼š

int main(){
    
    int i;

    ***************
    FILE *f = fopen("./test.txt", "r");
    while(!feof(f))
        fscanf(f, "%d", &i);
    fclose(f);
    printf("value of i is %d.\n", i);
    ***************

    printf("hope it works.\n");
    multiply();
  
  return 0;
}

int multiply()
{
    int i, sum;
    sum = 0;
    int *A = (int *)malloc(sizeof(int) * 10);
    int *B = (int *)malloc(sizeof(int) * 10);
    for(i = 0; i < 10; i++)
    {
        A[i] = i;
        B[i] = i;
    }
    for(i = 1; i < 10; i++)
        sum += A[i] * B[i];
    printf("value of sum is %d.\n", sum);
    
    return 0;
}

Everything is good if I comment the lines between *****, that's why I'm supposing the fault is related to fopen() function.

I've got stuck here for a week, hope to get your help.

0

There are 0 answers