Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in regex search #10773

Closed
olivier-75 opened this issue Nov 12, 2021 · 2 comments
Closed

Crash in regex search #10773

olivier-75 opened this issue Nov 12, 2021 · 2 comments

Comments

@olivier-75
Copy link

Description of the Issue

Specific wrong regex [a-é cause Notepad++ to crash

Steps to Reproduce the Issue

  1. Open search dialog and search for [a-é
  2. Enable Regular Expression search mode
  3. Press Find Next

Expected Behavior

Error message about wrong regex (missing ])

Actual Behavior

Close Notepad++

Debug Information

Notepad++ v8.1.9 (64-bit)
Build time : Oct 21 2021 - 23:37:53
Path : C:\src\npp.8.1.9.portable.x64\notepad++.exe
Command Line :
Admin mode : OFF
Local Conf mode : ON
Cloud Config : OFF
OS Name : Windows 10 Home (64-bit)
OS Version : 2009
OS Build : 19043.1348
Current ANSI codepage : 1252
Plugins : mimeTools.dll NppConverter.dll NppExport.dll

@chcg
Copy link
Contributor

chcg commented Nov 13, 2021

Exception in boost regex code:

 	KernelBase.dll!00007ffff5804f69()	Unbekannt
 	[Externer Code]	
>	notepad++.exe!boost::regex_error::raise() Zeile 69	C++
 	notepad++.exe!boost::re_detail_500::basic_regex_parser<wchar_t,boost::regex_traits<wchar_t,boost::w32_regex_traits<wchar_t>>>::fail(boost::regex_constants::error_type error_code, __int64 position, std::string message, __int64 start_pos) Zeile 230	C++
 	notepad++.exe!boost::re_detail_500::basic_regex_parser<wchar_t,boost::regex_traits<wchar_t,boost::w32_regex_traits<wchar_t>>>::fail(boost::regex_constants::error_type error_code, __int64 position, const std::string & message) Zeile 59	C++
 	notepad++.exe!boost::re_detail_500::basic_regex_parser<wchar_t,boost::regex_traits<wchar_t,boost::w32_regex_traits<wchar_t>>>::parse(const wchar_t * p1, const wchar_t * p2, unsigned int l_flags) Zeile 179	C++
 	notepad++.exe!boost::re_detail_500::basic_regex_implementation<wchar_t,boost::regex_traits<wchar_t,boost::w32_regex_traits<wchar_t>>>::assign(const wchar_t * arg_first, const wchar_t * arg_last, unsigned int f) Zeile 222	C++
 	notepad++.exe!boost::basic_regex<wchar_t,boost::regex_traits<wchar_t,boost::w32_regex_traits<wchar_t>>>::do_assign(const wchar_t * p1, const wchar_t * p2, unsigned int f) Zeile 647	C++
 	notepad++.exe!boost::basic_regex<wchar_t,boost::regex_traits<wchar_t,boost::w32_regex_traits<wchar_t>>>::assign(const wchar_t * p1, const wchar_t * p2, unsigned int f) Zeile 388	C++
 	notepad++.exe!boost::basic_regex<wchar_t,boost::regex_traits<wchar_t,boost::w32_regex_traits<wchar_t>>>::assign(const wchar_t * p, unsigned int f) Zeile 373	C++
 	notepad++.exe!boost::basic_regex<wchar_t,boost::regex_traits<wchar_t,boost::w32_regex_traits<wchar_t>>>::basic_regex<wchar_t,boost::regex_traits<wchar_t,boost::w32_regex_traits<wchar_t>>>(const wchar_t * p, unsigned int f) Zeile 341	C++
 	notepad++.exe!BoostRegexSearch::EncodingDependent<wchar_t,Scintilla::UTF8DocumentIterator>::compileRegex(const char * regex, const int compileFlags) Zeile 420	C++
 	notepad++.exe!BoostRegexSearch::EncodingDependent<wchar_t,Scintilla::UTF8DocumentIterator>::FindText(BoostRegexSearch::SearchParameters & search) Zeile 351	C++
 	notepad++.exe!BoostRegexSearch::FindText(Scintilla::Document * doc, __int64 startPosition, __int64 endPosition, const char * regexString, bool caseSensitive, bool __formal, bool __formal, int sciSearchFlags, __int64 * lengthRet) Zeile 310	C++
 	notepad++.exe!Scintilla::Document::FindText(__int64 minPos, __int64 maxPos, const char * search, int flags, __int64 * length) Zeile 2012	C++
 	notepad++.exe!Scintilla::Editor::SearchInTarget(const char * text, __int64 length) Zeile 4170	C++
 	notepad++.exe!Scintilla::Editor::WndProc(unsigned int iMessage, unsigned __int64 wParam, __int64 lParam) Zeile 6082	C++
 	notepad++.exe!Scintilla::ScintillaBase::WndProc(unsigned int iMessage, unsigned __int64 wParam, __int64 lParam) Zeile 1196	C++
 	notepad++.exe!ScintillaWin::WndProc(unsigned int iMessage, unsigned __int64 wParam, __int64 lParam) Zeile 2066	C++
 	notepad++.exe!ScintillaWin::DirectFunction(__int64 ptr, unsigned int iMessage, unsigned __int64 wParam, __int64 lParam) Zeile 3539	C++
 	notepad++.exe!ScintillaEditView::execute(unsigned int Msg, unsigned __int64 wParam, __int64 lParam) Zeile 217	C++
 	notepad++.exe!ScintillaEditView::searchInTarget(const wchar_t * text2Find, unsigned __int64 lenOfText2Find, unsigned __int64 fromPos, unsigned __int64 toPos) Zeile 2315	C++
 	notepad++.exe!FindReplaceDlg::processFindNext(const wchar_t * txt2find, const FindOption * options, FindStatus * oFindStatus, FindNextType findNextType) Zeile 1953	C++
 	notepad++.exe!FindReplaceDlg::run_dlgProc(unsigned int message, unsigned __int64 wParam, __int64 lParam) Zeile 1257	C++
 	notepad++.exe!StaticDialog::dlgProc(HWND__ * hwnd, unsigned int message, unsigned __int64 wParam, __int64 lParam) Zeile 262	C++
 	[Externer Code]	
 	notepad++.exe!Notepad_plus_Window::isDlgsMsg(tagMSG * msg) Zeile 380	C++
 	notepad++.exe!wWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * __formal, wchar_t * pCmdLine, int __formal) Zeile 716	C++
 	[Externer Code]	

with error message from exception:

"Found a closing ) with no corresponding opening parenthesis. The error occurred while parsing the regular expression: '[a-é>>>HERE>>>'."

, the exception is catched by the try catch block and should be presented via a tooltip, but there is another uncaught exception:

 	KernelBase.dll!00007ffff5804f69()	Unbekannt
 	[Externer Code]	
 	notepad++.exe!std::_Throw_range_error(const char * const _Message) Zeile 167	C++
 	notepad++.exe!std::wstring_convert<std::codecvt_utf8<wchar_t,1114111,0>,wchar_t,std::allocator<wchar_t>,std::allocator<char>>::from_bytes(const char * _First, const char * _Last) Zeile 412	C++
 	notepad++.exe!std::wstring_convert<std::codecvt_utf8<wchar_t,1114111,0>,wchar_t,std::allocator<wchar_t>,std::allocator<char>>::from_bytes(const std::string & _Bstr) Zeile 363	C++
>	notepad++.exe!s2ws(const std::string & str) Zeile 1228	C++
 	notepad++.exe!FindReplaceDlg::setStatusbarMessage(const std::wstring & msg, FindStatus staus, const char * pTooltipMsg) Zeile 3075	C++
 	notepad++.exe!FindReplaceDlg::processFindNext(const wchar_t * txt2find, const FindOption * options, FindStatus * oFindStatus, FindNextType findNextType) Zeile 2021	C++
 	notepad++.exe!FindReplaceDlg::run_dlgProc(unsigned int message, unsigned __int64 wParam, __int64 lParam) Zeile 1257	C++
 	notepad++.exe!StaticDialog::dlgProc(HWND__ * hwnd, unsigned int message, unsigned __int64 wParam, __int64 lParam) Zeile 262	C++
 	[Externer Code]	
 	notepad++.exe!Notepad_plus_Window::isDlgsMsg(tagMSG * msg) Zeile 380	C++
 	notepad++.exe!wWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * __formal, wchar_t * pCmdLine, int __formal) Zeile 716	C++
 	[Externer Code]	

probably caused by an issues with text encoding of é

@chcg
Copy link
Contributor

chcg commented Nov 13, 2021

The issue doesn't happen for just ascii characters. So [a-e is working as expected. N++ Version 7.9.5 is not affected because the tooltip extension with the boost regex exception text was not used there.

Probably still of interest which encoding is used for the regex exception text. It isn't UTF8 (seems to be E9, so something cutted from https://www.compart.com/en/unicode/U+00E9)

Could be fixed within s2ws by try/catch or usage of a user defined error string to avoid exception with std::range_error, see https://en.cppreference.com/w/cpp/locale/wstring_convert/from_bytes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants