Ajatt-Tools / anki.koplugin

KOReader plugin enabling Anki card generations for words looked up in the internal dictionary.
49 stars 6 forks source link

Koreader crashing when adding certain word to anki #7

Closed YashaNoos closed 3 months ago

YashaNoos commented 1 year ago

Hi it's me again:p I have notice that with the May 29 version some words cause koreader to crash, for exemple: When adding the word blench in this sentence blench I got this crash: BlenchCrash And when trying to add man in this sentence (I thought that maybe the !’ was somehow causing problem): Man I got this crash: ManCrash But then I tried to add mother from this sentence: mother And it just worked, without any trouble. So I don't know what's causing the crash, when a word in a specific sentence crash he always will. But the same word added to anki in other sentences won't cause any trouble. Sorry for keeping creating new issues every two day:p

nairyosangha commented 1 year ago

Sorry for keeping creating new issues every two day:p

Sorry for introducing bugs every two days ;^)

I would've run into this eventually, the context buffer for the sentence before the word you looked up could go out of bounds, but since that buffer is pretty big by default, you're only running into it when picking words near the end of the sentence (so it needs to prepend more than 50 words)

Should be fixed in https://github.com/Ajatt-Tools/anki.koplugin/commit/1e7bbfdcc9352d29023b04f6f1a16d0e15d137fb

YashaNoos commented 1 year ago

Just tested it and it works perfectly now. Thanks again for your reactivity your doing a great job with this project!

Inqurity commented 3 months ago

I have the same issue, I tried to add the word "pokładowy" and it crashed with the same error. crash.log

Inqurity commented 3 months ago

Can't reopen other people's issues...

Inqurity commented 3 months ago

Actually, I tried to add "wzrok" and it worked, so that's probably an issue with Polish letters specifically. @nairyosangha, I hope this bug report finds you well

nairyosangha commented 3 months ago

I don't think this is the same issue, although it indeed looks very similar..

I would like to see the document in question if you don't mind. I don't think it has anything to do with Polish letters at all.

06/01/24-19:53:29 INFO  AnkiNote#get_custom_context() 1 0 1 0 
06/01/24-19:55:59 INFO  (re)initializing context buffer with size: 50 
06/01/24-19:55:59 INFO  after reinit: prev table = 61, next table = 344 
06/01/24-19:55:59 INFO  AnkiNote#get_custom_context() 1 0 1 0 
06/01/24-19:55:59 INFO  (re)initializing context buffer with size: 100 
06/01/24-19:55:59 INFO  before reinit: prev table = 61, next table = 344 
06/01/24-19:55:59 INFO  after reinit: prev table = 61, next table = 722 
./luajit: plugins/anki.koplugin/ankinote.lua:87: Something went wrong when parsing previous context! idx: 0, context_table size: 61
stack traceback:

Looking at all the log messages for 19:55:59, I'm seeing that the plugin tried to first initialize the context, that part is normal. Then it runs out of context, this was a pretty long sentence apparently, so it tries to expand it again with double the size, BUT:

06/01/24-19:55:59 INFO  (re)initializing context buffer with size: 100 
06/01/24-19:55:59 INFO  before reinit: prev table = 61, next table = 344 
06/01/24-19:55:59 INFO  after reinit: prev table = 61, next table = 722 

Even though it tried to grow the context buffer (size 100 instead of 50), we still did not get any more context for the part of the sentence coming before the word you looked up, it's still 61. I made the assumption that if I ask KOReader for more context I actually would get more context on both sides of the word I'm asking context for, but apparently that's not the case. I did not know this could happen and I don't know why it would, is this start of a chapter maybe?

Inqurity commented 3 months ago

It is the start of the chapter, I tried to add another word on the same page as "pokładowy" but without any Polish letters and it also crashed. Here's the book in question. Stanisław, Lem - Solaris.zip

Inqurity commented 3 months ago

Though it's not exactly the same book, the one on my device is the same but converted into .mobi with Calibre, I'll upload that too in a moment

Inqurity commented 3 months ago

Here it is Solaris - Lem Stanislaw.zip

nairyosangha commented 3 months ago

I assume you mean pokładowego on the very first page, I'm not finding anything for pokładowy.

In that case I can reproduce it, since it's the very beginning of the book it's obviously not gonna be able to get any more context, so I'll have to check that

Can you check if it works now? https://github.com/Ajatt-Tools/anki.koplugin/commit/bf83ae93f74bd3002cd92d9dbf68c280c7cd31b4

Inqurity commented 3 months ago

It works now, thank you for being active and helpful!!

Inqurity commented 3 months ago

And sorry for the confusion, pokładowego in a declension of pokładowy