Ticket #329 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

gil checks in .pxd files cannot rely on type information

Reported by: scoder Owned by: dagss
Priority: major Milestone: 0.12
Component: Parsing Keywords:
Cc:

Description

According to Ondrej Certik, this currently fails in cython-unstable when written in a .pxd file:

cdef BiFormFnVol BF_SYM = <BiFormFnVol> 1

 http://thread.gmane.org/gmane.comp.python.cython.devel/6319/focus=6324

Error traceback:

Error converting Pyrex file to C:
------------------------------------------------------------
...
    ctypedef scalar (*BiFormFnVol)(RealFunction *fu, RealFunction *fv,
            RefMap *ru, RefMap *rv)

    ctypedef scalar (*LiFormFnVol)(RealFunction *fv, RefMap *rv)

    cdef BiFormFnVol BF_SYM = <BiFormFnVol> 1
                             ^
------------------------------------------------------------

/home/ondrej/repos/hermes2d/python/hermes2d/_hermes2d.pxd:110:30:
Compiler crash in GilCheck

ModuleNode.body = StatListNode(_hermes2d.pxd:1:0)
StatListNode.stats[5] = CDefExternNode(_hermes2d.pxd:31:5,
    include_file = 'hermes2d.h')
CDefExternNode.body = StatListNode(_hermes2d.pxd:34:4)
StatListNode.stats[5] = SingleAssignmentNode(_hermes2d.pxd:110:9)
SingleAssignmentNode.rhs = TypecastNode(_hermes2d.pxd:110:30)
File 'ExprNodes.py', line 4006, in gil_check: TypecastNode(_hermes2d.pxd:110:30)

Compiler crash traceback from this point on:
  File "/home/ondrej/usr/lib/python/Cython/Compiler/ExprNodes.py",
line 4007, in gil_check
    if self.type.is_pyobject and self.is_temp:
AttributeError: 'NoneType' object has no attribute 'is_pyobject'

The only reason (that I can see) to do gil checks in a .pxd file is for inline/buffer functions.

Change History

Changed 5 years ago by dagss

  • owner changed from somebody to dagss
  • status changed from new to assigned

Changed 5 years ago by dagss

  • status changed from assigned to closed
  • resolution set to fixed

I did this:

  • gil_check renamed to nogil_check
  • is now only called when nogil is True, that is, no function call happens outside of nogil sections

This also makes sure that the nogil_check methods are only called when type info is available.

 http://hg.cython.org/cython-unstable/rev/67a370779b96

Note: See TracTickets for help on using tickets.