popen的valgrind错误的确切原因

时间:2014-08-06 19:13:41

标签: c valgrind

我正在尝试在C中的while循环中运行一个名为BLAST的生物软件。除了使用popen的部分之外,Valgrind并没有抱怨。代码中有问题的部分如下,并且每次在while循环中创建BLAST program-xxx_temp.txt和yyy_temp.txt的输入文件。

while(!feof(fpf1) && flag1 == 0)
{
    flag2=0;
    while(!feof(fpf2) && flag2 == 0)
    {
        if((fp = popen("blastp -outfmt '6 qseqid sseqid pident evalue qcovs' -query gwidd_temp.txt -subject uniprot_temp.txt", "r")) != NULL)
        {
            while(fgets(buffer,sizeof(buffer),fp) != NULL)
            fprintf(f1,"%s",buffer);
            pclose(fp);
        }
    }
    flag1=0;
    fseek(fpf2,0L,SEEK_SET);
}   

Valgrind错误是:

$ valgrind --tool=memcheck --leak-check=full --track-origins=yes --gen-suppressions=yes ./test
==8312== Memcheck, a memory error detector
==8312== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==8312== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==8312== Command: ./test
==8312== 
-
-
-
==8312== Conditional jump or move depends on uninitialised value(s)
==8312==    at 0x1000AC88B: pclose (in /usr/lib/libSystem.B.dylib)
==8312==    by 0x100001951: main (in ./test)
==8312==  Uninitialised value was created by a stack allocation
==8312==    at 0x100001C22: main (in ./test)
==8312== 
==8312== 
==8312== ---- Print suppression ? --- [Return/N/n/Y/y/C/c] ---- y
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:pclose
   fun:main
}
==8312== Syscall param wait4(pid) contains uninitialised byte(s)
==8312==    at 0x1000A2B2A: wait4 (in /usr/lib/libSystem.B.dylib)
==8312==    by 0x100001951: main (in ./test)
==8312==  Uninitialised value was created by a stack allocation
==8312==    at 0x100001C22: main (in ./test)
==8312== 
==8312== 
==8312== ---- Print suppression ? --- [Return/N/n/Y/y/C/c] ---- y
{
   <insert_a_suppression_name_here>
   Memcheck:Param
   wait4(pid)
   fun:wait4
   fun:main
}
-
-
-
==8312== 
==8312== HEAP SUMMARY:
==8312==     in use at exit: 12,376 bytes in 4 blocks
==8312==   total heap usage: 84 allocs, 80 frees, 421,696 bytes allocated
==8312== 
==8312== LEAK SUMMARY:
==8312==    definitely lost: 0 bytes in 0 blocks
==8312==    indirectly lost: 0 bytes in 0 blocks
==8312==      possibly lost: 0 bytes in 0 blocks
==8312==    still reachable: 12,376 bytes in 4 blocks
==8312==         suppressed: 0 bytes in 0 blocks
==8312== Reachable blocks (those to which a pointer was found) are not shown.
==8312== To see them, rerun with: --leak-check=full --show-reachable=yes
==8312== 
==8312== For counts of detected and suppressed errors, rerun with: -v
==8312== ERROR SUMMARY: 24 errors from 2 contexts (suppressed: 0 from 0)

请帮我解决这些错误。

如果您需要查看我最早可以提供的完整代码。

0 个答案:

没有答案