Dushistov / sdcv

https://dushistov.github.io/sdcv/
GNU General Public License v2.0
300 stars 44 forks source link

Certain words lead to segmentation faults #81

Closed Vuizur closed 2 years ago

Vuizur commented 2 years ago

I created a Russian-Russian dictionary from Wiktionary, exported to stardict using pyglossary. For the majority of words it works fine, but for some words it crashes with a segmentation fault, for example for the words "и́менно" or "су́дно".

When I use Goldendict to look up these words, then they are found correctly. The line endings of the ifo file are correct this time as far as I can tell.

Dushistov commented 2 years ago

Are you sure that this is not duplicate of #79 , I tried your dictionary and works just fine:

❯ ./sdcv -u 'Русский Викисловарь (ru-ru)' 'и́менно'
Found 2 items, similar to и́менно.
0)Русский Викисловарь (ru-ru)-->Пи́мен
1)Русский Викисловарь (ru-ru)-->сме́нный
Your choice[-1 to abort]: 

Then I add your dictionary from #79 with line DOS line ending and I see crash. Then I fixed line endings:

dos2unix /home/evgeniy/.stardict/dic/russian/russian.ifo

and all works without problems:

❯ ./sdcv и́менно | tee
Found 1 items, similar to и́менно.
-->Russian-English Dictionary (ru-en)!
-->и́менно

<p>just, exactly, actually; used to emphasize the meaning of the following word or what comes later and sometimes can be rather difficult to translate it in English.</p><p>namely, to wit, rather; used to specify something or when listing to specify something.</p><p>indeed, rather; used to emphasize the agreement or confirmation.</p>
Vuizur commented 2 years ago

The problem with this newer (Ru-Ru) dictionary is that it does have LF file endings for the IFO file (at least according to VS code). So I don't know what I could fix. For my tests I used the interactive mode (using the version downloaded using ubuntu/apt), maybe because of that I get different results. An example for strange behaviour would be:

pux@DESKTOP-L1488R9:/usr/share$ sdcv
Enter word or phrase: именно
Found 1 items, similar to именно.
-->Русский Викисловарь (ru-ru)
-->и́менно

<ul><li>частица выражает усиление, уточнение, решительное подтверждение <i>◆ Я видел тогда именно этого человека.    </i></li><li>союз вводит полное перечисление</li></ul>

Enter word or phrase: и́менно
Segmentation fault

So here it works when I look for the inflection (the dictionary contains именно as the inflection of и́менно), but not when I look for the lemma itself, unfortunately.

Vuizur commented 2 years ago

I looked more at it and think that it really is caused by the line endings, not only windows line endings, but also PS/... line endings, but this time inside the .dict file. I will try to remove them and see what happens.

ilius commented 2 years ago

If you remove or insert anything from/into .dict file, glossary will break, unless you update .idx file as well.