Problem finding the cause of a random crash in Document::NotifyModified(DocModification mh)

61 views
Skip to first unread message

ekopa...@gmail.com

unread,
Jun 6, 2024, 5:02:01 AMJun 6
to scintilla-interest
I'm trying to find out what might cause this crash

Document_NotifModified.PNG
This happened after typing "self ", the word self with a space, in an empty python buffer.
ScintillaWin_AddWString.PNG
Is it normal that even though wsv[0] is 32 (space), the docChar size is 0?
To be 100% clear, this ONLY happens when Notepad++ loads my plugin, I've never seen it occur without my plugin, but nothing in the stack trace points to a source from my plugin.
And all my plugin is doing is calling searchintarget and using indicators to flag matches.
There are no other threads in play either. I'm running out of ideas and I hope someone else has some.

Thank you
Eren

Neil Hodgson

unread,
Jun 6, 2024, 7:01:40 AMJun 6
to Scintilla mailing list
ekopa…:

> <Document_NotifModified.PNG>

Its pretty strange for watcher.watcher to be 0xFF… as its a pointer and should be set up in an AddWatcher call with a pointer to a valid Watcher. Check the implementation code for AddWatcher calls and trace them. 0xFF.. could be uninitialized memory but it shouldn't be occurring here.

> This happened after typing "self ", the word self with a space, in an empty python buffer.
> <ScintillaWin_AddWString.PNG>
> Is it normal that even though wsv[0] is 32 (space), the docChar size is 0?

More likely that the debugger is reporting poorly.

It's possible there is some optimization occurring or different pieces of code are being compiled with different flags. Try cleaning and recompiling.

> To be 100% clear, this ONLY happens when Notepad++ loads my plugin, I've never seen it occur without my plugin, but nothing in the stack trace points to a source from my plugin.

There are two calls to AddWString inside KeyMessage, with WM_CHAR or WM_UNICHAR and that should be checked.

> And all my plugin is doing is calling searchintarget and using indicators to flag matches.

Its easy to reuse the target in unexpected ways in reentrant code so see if your code is being called with other uses of the target in up or down-stack calls.

Neil

ekopa...@gmail.com

unread,
Jun 6, 2024, 8:25:27 AMJun 6
to scintilla-interest
Neil,
thank you very much for the help and tips.
I will apply them and see if I can solve the mystery.

Thank you
Eren

ekopa...@gmail.com

unread,
Jun 11, 2024, 5:48:09 AMJun 11
to scintilla-interest
Ok, unfortunately I misinterpreted the documentation, again.

No modifications may be performed while in a SCN_MODIFIED event.

I had understood this to mean "text modifications" and I actually only wanted to change styles. 
Lessons learnt.

Eren

Neil Hodgson

unread,
Jun 11, 2024, 7:41:40 PMJun 11
to Scintilla mailing list
ekopa…:

> No modifications may be performed while in a SCN_MODIFIED event.
>
> I had understood this to mean "text modifications" and I actually only wanted to change styles.

It's not quite as clear cut as that makes out. While it may not be possible to allow making the changes you want inside SCN_MODIFIED, there may be ways to harden the code and prevent crashes if they are caused by something like writing outside allocated memory. Do you have any more information on what specifically occurred?

Neil


ekopa...@gmail.com

unread,
Jun 12, 2024, 1:19:22 PMJun 12
to scintilla-interest
Neil, not yet, but I think I should be able to provide the information in the next few days.

Eren
Reply all
Reply to author
Forward
0 new messages