[Python] Leak in python API
Giorgio Zoppi
giorgio.zoppi a gmail.com
Mer 24 Giu 2009 12:48:13 CEST
Io ho un leak in un mio test case:
int test_run_python(const char* filename)
{
FILE* fp;
FILE* result;
int value;
char buf[256];
char cwd[PATH_MAX];
char rsidir[PATH_MAX];
int nchar = 0;
getcwd(cwd,PATH_MAX);
snprintf(rsidir,sizeof(rsidir),"%s/%s",cwd,"rsi/");
chdir(rsidir);
memset(buf,0,sizeof(buf));
Py_Initialize ();
fp = fopen (filename, "r+");
PyRun_SimpleFile (fp, filename);
Py_Finalize();
fclose(fp);
value = -1;
result = fopen("/tmp/result","r");
if (result!=NULL)
{
fgets(buf,sizeof(buf),result);
nchar = strlen(buf);
buf[nchar-1] = '\0';
value = atoi(buf);
fclose(result);
}
chdir(cwd);
unlink("/tmp/result");
return value;
}
=1963== 9,672 bytes in 27 blocks are possibly lost in loss record 38 of 43
==1963== at 0x4006AEE: malloc (vg_replace_malloc.c:207)
==1963== by 0x6CBBF9B: PyObject_Malloc (in /usr/lib/libpython2.5.so.1.0)
==1963== by 0x6D32884: _PyObject_GC_Malloc (in /usr/lib/libpython2.5.so.1.0)
==1963== by 0x6D32987: _PyObject_GC_NewVar (in /usr/lib/libpython2.5.so.1.0)
==1963== by 0x6CA2109: PyFrame_New (in /usr/lib/libpython2.5.so.1.0)
==1963== by 0x6D09323: PyEval_EvalCodeEx (in /usr/lib/libpython2.5.so.1.0)
==1963== by 0x6CA3375: (within /usr/lib/libpython2.5.so.1.0)
==1963== by 0x6C83396: PyObject_Call (in /usr/lib/libpython2.5.so.1.0)
==1963== by 0x6C8A877: (within /usr/lib/libpython2.5.so.1.0)
==1963== by 0x6C83396: PyObject_Call (in /usr/lib/libpython2.5.so.1.0)
==1963== by 0x6CD1565: (within /usr/lib/libpython2.5.so.1.0)
==1963== by 0x6CCFE34: (within /usr/lib/libpython2.5.so.1.0)
Idee?
Maggiori informazioni sulla lista
Python