New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault when calling unbound cpdef method with wrong self type #1903

Open
JelleZijlstra opened this Issue Oct 2, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@JelleZijlstra
Contributor

JelleZijlstra commented Oct 2, 2017

I have the following code:

# cycrash.pxd
cdef class FutureBase(object):
    cdef public object _error
    cpdef object error(self)

# cycrash.py
class FutureBase(object):
    def error(self):
        return self._error

When I compile it (using either 0.26.1 or 0.27.1) I get:

$ python -c 'import cycrash; print(cycrash.FutureBase.error(1))'
Segmentation fault

The root cause seems to be that we access the self._error attribute on self without checking that self is actually an instance of the FutureBase extension class.

@scoder

This comment has been minimized.

Show comment
Hide comment
@scoder

scoder Oct 3, 2017

Contributor

I fail to reproduce this. I also tried with and without the binding=True directive, but I always get a runtime TypeError and not a crash. Can you confirm that the above code is enough for you to reproduce this? No special directives or anything else involved? How do you compile it?

Contributor

scoder commented Oct 3, 2017

I fail to reproduce this. I also tried with and without the binding=True directive, but I always get a runtime TypeError and not a crash. Can you confirm that the above code is enough for you to reproduce this? No special directives or anything else involved? How do you compile it?

@JelleZijlstra

This comment has been minimized.

Show comment
Hide comment
@JelleZijlstra

JelleZijlstra Oct 3, 2017

Contributor

We use a special script that among others passes --line-directives -X infer_types=True to Cython. I don't have time right now to check if those make a difference, but infer_types sounds suspicious.

Contributor

JelleZijlstra commented Oct 3, 2017

We use a special script that among others passes --line-directives -X infer_types=True to Cython. I don't have time right now to check if those make a difference, but infer_types sounds suspicious.

@scoder

This comment has been minimized.

Show comment
Hide comment
@scoder

scoder Oct 3, 2017

Contributor

I tried that, but it doesn't make a difference for me.

Contributor

scoder commented Oct 3, 2017

I tried that, but it doesn't make a difference for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment