TAGS :Viewed: 15 - Published at: a few seconds ago

[ python ahocorasick segment fault when add to tree ]

I got segment fault when adding to tree using ahocorasick module in python, I tried 0.9 and 1.0pre same result, any help would be appreciated. Thanks

[mine@ao ~]$ python
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> import ahocorasick
>>> tree = ahocorasick.KeywordTree()
>>> tree.add("alpha")

Segmentation fault (core dumped)

Answer 1


I just came across the same problem. The problem is that the size of size_t is different on 64 bit machines, so the length of the string which is being added is passed wrong to the internal add function(eg 139839840190468(0x7f2f00000004) bytes instead of 4).

I created a github project and applied the patch, check this.