zufuliu / notepad4

Notepad4 (Notepad2⨯2, Notepad2++) is a light-weight Scintilla based text editor for Windows with syntax highlighting, code folding, auto-completion and API list for many programming languages and documents, bundled with file browser plugin matepath.
Other
2.42k stars 174 forks source link

A strange exception occurs when inputting specific characters. #775

Closed vhkj closed 1 month ago

vhkj commented 3 months ago

Exception details shows in the gif picture below.. When I use Chinese Larry Input method(双拼输入法) and type "#" then type "i" or "u" ( in Chinese larry Input method, "ch" replace "i" ,"sh" replace "u") , it happends. This bug will also be reproduced in the Release version

I can't find the position to fix it.

thsbug

vhkj commented 3 months ago

https://i.postimg.cc/ncJBW02t/thsbug.gif

zufuliu commented 3 months ago

Reproduceable with SciTE (set ime.interaction=0), temporary workaround is using inline mode IME. image

Adding a breakpoint after case WM_IME_COMPOSITION: seems hide the bug.

zufuliu commented 3 months ago

The crash is due to ImeOnDocumentFeed(), no crashes after comment out if (wParam == IMR_DOCUMENTFEED) block: https://github.com/zufuliu/notepad2/blob/9399a27265622ae8409761f549e29f6b9dde073a/scintilla/win32/ScintillaWin.cxx#L1925-L1933

vhkj commented 3 months ago

The crash is due to ImeOnDocumentFeed(), no crashes after comment out if (wParam == IMR_DOCUMENTFEED) block:

https://github.com/zufuliu/notepad2/blob/9399a27265622ae8409761f549e29f6b9dde073a/scintilla/win32/ScintillaWin.cxx#L1925-L1933

Nice. It seems to have little impact on normal use. By the way, I wanna know how you located the bug location, could you please give me some advice?

zufuliu commented 3 months ago

Reported as https://sourceforge.net/p/scintilla/bugs/2433/, please use inline mode IME for now.

zufuliu commented 3 months ago

By the way, I wanna know how you located the bug location, could you please give me some advice?

First, I guess its stack buffer overrun, then added some printf() inside IME codes, and run release version form command line (change following to #if 1 ). https://github.com/zufuliu/notepad2/blob/65ccf25dba933ce233793f0612910d0d7a56b0ca/src/Notepad2.c#L522-L530

vhkj commented 3 months ago

By the way, I wanna know how you located the bug location, could you please give me some advice?

First, I guess its stack buffer overrun, then added some printf() inside IME codes, and run release version form command line (change following to #if 1 ).

https://github.com/zufuliu/notepad2/blob/65ccf25dba933ce233793f0612910d0d7a56b0ca/src/Notepad2.c#L522-L530

Ok, thanks for u. I'll try it.

zufuliu commented 3 months ago

Fixed by 339e3fa8805f7c9411bf6e6df8d295b91b5a72a5.

zufuliu commented 3 months ago

Hi @maboroshin, can you check whether window mode IMR_DOCUMENTFEED (issue #127) still works after 339e3fa8805f7c9411bf6e6df8d295b91b5a72a5?

maboroshin commented 3 months ago

Thanks. It has been functional since 339e3fa.

Test method used: https://github.com/zufuliu/notepad2/issues/127#issuecomment-1537366797

results:

zufuliu commented 3 months ago

Good to know it works. Just a bit strange as git blame -L:ImeOnDocumentFeed ScintillaWin.cxx says IMR_DOCUMENTFEED was added in 72ef5d61d3b2958f9c441a8dbcad83ed96e6d426 (v4.23.06r4862), and no changes to the function until 65ccf25dba933ce233793f0612910d0d7a56b0ca and 339e3fa8805f7c9411bf6e6df8d295b91b5a72a5.