Skip to content
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

out-of-order assignment with strings causes segfault #716

Closed
robertwb opened this issue Dec 10, 2008 · 12 comments
Closed

out-of-order assignment with strings causes segfault #716

robertwb opened this issue Dec 10, 2008 · 12 comments

Comments

@robertwb
Copy link
Contributor

Hello,

In cython 1474:7f1b96cad687, the following code results in a segfault. It seems a relevant check for None is omitted because of the assignment, even though the assignment comes later.

def crash():
    print "%s" % s
    cdef str s = "Test"

When crash() is run, the program segfaults. However, the following code segments behave correctly, printing None.

def nocrash():
    print "%s" % s
    cdef str s

and

def nocrash():
    cdef str s = None
    print "%s" % s

Furthermore, assigning None to the s afterwards also causes it to crash (compare above).

def crash(): 
    print "%s" % s
    cdef str s = None

Thanks!
--Hoyt

Migrated from http://trac.cython.org/ticket/158

@robertwb
Copy link
Contributor Author

scoder changed milestone from wishlist to 0.11
commented

@robertwb
Copy link
Contributor Author

robertwb commented Jan 3, 2009

scoder commented

There are two problems involved here: one is the missing None check that http://trac.cython.org/ticket/166 describes, the other problem is that initial assignments of a cdef apparently fail to take previous usages of the name into account. This is a bit tricky to fix due to Cython's scoping rules: variables exist inside the entire scope (i.e. module/function), regardless of their point of declaration.

Another bug that flow control analysis could potentially fix...

@robertwb
Copy link
Contributor Author

robertwb commented Jan 4, 2009

@dagss commented

Would it be help to simply disable the ability to declare variables after they are used? This is rather easily checked without full flow control analysis.

@robertwb
Copy link
Contributor Author

@robertwb commented

Yes, I think we should disallow variable declarations after they are used.

@robertwb
Copy link
Contributor Author

@robertwb changed milestone from 0.11 to 0.11.1
commented

@robertwb
Copy link
Contributor Author

@robertwb changed priority from minor to critical
commented

This is a pretty bad bug, but it'll be more than a quick fix and it's not a regression so I don't want to hold up 0.11 for it.

@robertwb
Copy link
Contributor Author

@dagss changed owner from somebody to Kurt Smith
commented

@robertwb
Copy link
Contributor Author

@robertwb
Copy link
Contributor Author

@dagss commented

Note that this is almost done, there's a patch on the mailing list.

@robertwb
Copy link
Contributor Author

@dagss changed resolution to fixed
status from new to closed
commented

http://hg.cython.org/cython-devel/rev/478a5cfba350

@robertwb
Copy link
Contributor Author

@dagss commented

To be clear, this was fixed by making Hoyt's example raise a compilation error.

@robertwb
Copy link
Contributor Author

robertwb commented Apr 9, 2009

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

No branches or pull requests

1 participant