pyc files problem

Dave Angel davea at ieee.org
Wed May 6 04:57:00 EDT 2009


Gabriel Genellina wrote:
> <div class="moz-text-flowed" style="font-family: -moz-fixed">En Wed, 
> 06 May 2009 00:43:25 -0300, Mohamed Lrhazi <lrhazi at gmail.com> escribió:
>
>> My code sends a pointer to a Python function to a C library, using
>> ctypes module. When my program restarts, after a crash or normal
>> exit... it cannot start again without sigfaulting
>
> Do you mean that, if you delete the .pyc files your program runs 
> properly, but if you keep the .pyc files your program crashes?
> That's very strange...
>
>> What is the proper way around this problem? other than adding code to
>> delete the cache files?
>
> There is no "proper way around" the problem; it should not exist in 
> the first place!
>
> Have you read the note at the end of the "Callback" section in the 
> ctypes documentation?
> """Important note for callback functions:
>
> Make sure you keep references to CFUNCTYPE objects as long as they are 
> used from C code. ctypes doesn't, and if you don't, they may be 
> garbage collected, crashing your program when a callback is made."""
>
> There is a ctypes-specific list: 
> https://lists.sourceforge.net/lists/listinfo/ctypes-users
>
1) Is it true (as Gabriel asks) that deleting the .pyc files solves the 
problem?
2) If so, have you investigated to see which one of them gets 
corrupted?  This isn't necessarily the problem, it could also be timing, 
or related to the order of the memory allocation pool.
3) When you get the segment fault, what does you C debugger show?  
What's happening at the time of the crash?
4) Is either the C code or the Python code multithreaded?
5) Are you running it under a Python debugger?




More information about the Python-list mailing list