cyac icon indicating copy to clipboard operation
cyac copied to clipboard

Segmentation fault when iterating over AC trie

Open stephankoe opened this issue 4 years ago • 3 comments

Issue

When iterating over an AC trie, a segmentation fault occurs. For example:

import cyac
trie = cyac.AC.build(['hello', 'world'])
for w in trie:
    print(w)

Output:

hello
world










Segmentation fault

However, AC.items() is works as expected.

Environment

  • Ubuntu 18.04
  • Python 3.6.9
  • Cython 0.29.21
  • cyac 1.4

stephankoe avatar Jul 07 '22 03:07 stephankoe

it seems that it's cython's bug. AC has not implemented iter method. In my python environment, your code complains:

lib/cyac/ac.pyx in cyac.ac.AC.__getitem__()

lib/cyac/trie.pyx in cyac.trie.Trie.__getitem__()

AttributeError: 'NoneType' object has no attribute 'decode'

chenkovsky avatar Jul 12 '22 02:07 chenkovsky

@stephankoe please try this branch. https://github.com/nppoly/cyac/pull/14

chenkovsky avatar Jul 12 '22 04:07 chenkovsky

Yes, that branch is working. Thanks!

stephankoe avatar Jul 13 '22 12:07 stephankoe