Opened 7 years ago

Closed 7 years ago

#329 closed defect (fixed)

gil checks in .pxd files cannot rely on type information

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


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

cdef BiFormFnVol BF_SYM = <BiFormFnVol> 1

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

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 '', 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/",
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 (2)

comment:1 Changed 7 years ago by dagss

  • Owner changed from somebody to dagss
  • Status changed from new to assigned

comment:2 Changed 7 years ago by dagss

  • Resolution set to fixed
  • Status changed from assigned to closed

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.

Note: See TracTickets for help on using tickets.