[Pyrex] Pyrex 0.9: Compiled code produces segmentation fault

Paul Prescod paul at prescod.net
Mon Feb 2 01:16:42 CET 2004


Perhaps you could try something for me? Change the generated C code to 
add this line from Pyrex 0.8.2:

   __pyx_type_3vec_vec3iter.tp_free = _PyObject_GC_Del;

Do this right before the PyType_Ready function for vec3iter:

   if (PyType_Ready(&__pyx_type_3vec_vec3iter) < 0) {__pyx_filename = 
__pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}

(be careful to put the line before the _vec3iter PyType_Ready call, not 
before the _vec3 PyType_Ready call...see [1] below)

I believe the relevant Python change is here:

http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Objects/typeobject.c?r1=2.232&r2=2.233

Greg probably remembers why he took at those explicit tp_free settings. 
Perhaps he tested and saw that Python did it itself (in recent versions) 
and decided it was superfluous.

  Paul Prescod

[1] DL_EXPORT(void) initvec09(void); /*proto*/
DL_EXPORT(void) initvec09(void) {
   PyObject *__pyx_1 = 0;
   PyObject *__pyx_2 = 0;
   __pyx_m = Py_InitModule4("vec09", __pyx_methods, 0, 0, 
PYTHON_API_VERSION);
   __pyx_b = PyImport_AddModule("__builtin__");
   PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b);
   if (PyType_Ready(&__pyx_type_3vec_vec3) < 0) {__pyx_filename = 
__pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}
   if (PyObject_SetAttrString(__pyx_m, "vec3", (PyObject 
*)&__pyx_type_3vec_vec3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno 
= 3; goto __pyx_L1;}
   __pyx_ptype_3vec_vec3 = &__pyx_type_3vec_vec3;
   __pyx_type_3vec_vec3iter.tp_free = _PyObject_GC_Del;  /* HERE!!!! */
   if (PyType_Ready(&__pyx_type_3vec_vec3iter) < 0) {__pyx_filename = 
__pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
   if (PyObject_SetAttrString(__pyx_m, "vec3iter", (PyObject 
*)&__pyx_type_3vec_vec3iter) < 0) {__pyx_filename = __pyx_f[0]; 
__pyx_lineno = 9; goto __pyx_L1;}
   __pyx_ptype_3vec_vec3iter = &__pyx_type_3vec_vec3iter;
  ...







More information about the Pyrex mailing list