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

Segmentation fault in copy constructor of StdTransducer #25

Open
GeorgeArgyros opened this issue Sep 18, 2015 · 4 comments
Open

Segmentation fault in copy constructor of StdTransducer #25

GeorgeArgyros opened this issue Sep 18, 2015 · 4 comments

Comments

@GeorgeArgyros
Copy link

Although I cannot find it in the API description (http://pyfst.github.io/api.html) it looks like there exists a copy constructor for the StdTransducer and StdAcceptor classes. However, when I am trying to initialize a new object like that I get a segmentation fault.
Example:

>>> import fst
>>> x= fst.StdTransducer()
>>> x.add_arc(0,0,'1','0')
>>> x[0].final = True
>>> y = fst.StdTransducer(x)
Segmentation fault: 11

Is this a bug, or I am doing something unexpected for the library?

Thanks!

@kylebgorman
Copy link

That looks like it should work to me, given the code in line 338 oneward in
_fst.pyx.tpl

.

On Fri, Sep 18, 2015 at 6:04 PM, GeorgeArgyros [email protected]
wrote:

Although I cannot find it in the API description (
http://pyfst.github.io/api.html) it looks like there exists a copy
constructor for the StdTransducer and StdAcceptor classes. However, when I
am trying to initialize a new object like that I get a segmentation fault.
Example:

import fst
x= fst.StdTransducer()
x.add_arc(0,0,'1','0')
x[0].final = True
y = fst.StdTransducer(x)
Segmentation fault: 11

Is this a bug, or I am doing something unexpected for the library?

Thanks!


Reply to this email directly or view it on GitHub
#25.

@GeorgeArgyros
Copy link
Author

Yes, this is how I figured out that a copy constructor exists in the first place. However, I am getting the seg fault mentioned above. I am running pyfst on OSX Yosemite btw.

@matichorvat
Copy link

I can replicate the segmentation fault.

You are correct that such behavior is indicated to be supported by the cython code. However, looking at https://github.com/vchahun/pyfst/blob/master/fst/__init__.py#L8, the initialization function that is actually used does not match the one in cython code. Namely, it does not anticipate a source parameter. Also, notice that https://github.com/vchahun/pyfst/blob/master/fst/_fst.pyx.tpl#L342 does not actually try and copy the source FST, but rather tries to copy itself. Since up to that point, self.fst has not been assigned yet, I believe that is what produces the segmentation fault.

@matichorvat
Copy link

I tried to fix this behavior but unfortunately couldn't. An easy workaround is to use:

>>> import fst
>>> x= fst.StdTransducer()
>>> x.add_arc(0,0,'1','0')
>>> x[0].final = True
>>> y = x.copy()

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

No branches or pull requests

3 participants