horribly slimy segault c-extension
imbosol at aerojockey.com
Sun Jun 1 00:16:29 CEST 2003
John Does wrote:
> There should be no need for me to show all my code for this issue.
> First off: i run a program and it sefaults normally, but when i run it
> through gdb it does not.
> Here are the relevant lines of code:
> printf("q:%i \n",Q->ob_refcnt);
> printf("qa:%i \n",Q->ob_refcnt);
> Q = newQ ;
> printf("qaa:%i \n",Q->ob_refcnt);
> And the output:
> Segmentation fault
> Without asking me for any more code, can someone give me some
> precise steps that I could take to begin resolving/exposing this
First thing to try:
/* printf("qa:%i \n",Q->ob_refcnt); */
Q = newQ ;
You're trying to access Q after its refcount fell to zero. Py_DECREF
frees the memory pointed at by Q when that happens. Trying to access
freed memory (as your printf does) is an undefined operation, and
could very well segfault.
Just a guess, does the DECREFed object have a large memory footprint
(say, more than 8K)?
More information about the Python-list