horribly slimy segault c-extension

Lyle Johnson lyle at users.sourceforge.net
Mon Jun 2 10:40:13 EDT 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);
>         Py_DECREF(Q);
>         printf("qa:%i \n",Q->ob_refcnt);
>         Q = newQ ;
>         printf("qaa:%i \n",Q->ob_refcnt);
> 
> And the output:
> 
> q:1 
> 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 issue.

One issue you might investigate is whether the memory pointed-to by 'Q' 
has been trashed before the first line even executes. In other words, 
you may just be lucky (for some values of "lucky") that the part of the 
memory that the ob_refcnt field occupies wasn't corrupted, but the 
object as a whole is corrupted. You might try running your program 
through a memory debugging tool like Valgrind 
(http://developer.kde.org/~sewardj) to see what comes up.





More information about the Python-list mailing list