Summary: | Kate crashes when opening TypeScript (.ts) file with LSP plugin enabled | ||
---|---|---|---|
Product: | [Applications] kate | Reporter: | qewer <yerdemergul> |
Component: | general | Assignee: | KWrite Developers <kwrite-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | crash | CC: | waqar.17a |
Priority: | NOR | Keywords: | drkonqi |
Version: | 21.12.0 | ||
Target Milestone: | --- | ||
Platform: | Arch Linux | ||
OS: | Linux | ||
Latest Commit: | https://invent.kde.org/utilities/kate/commit/87aff4f47f079d32aa286f074cb0ecce8b1304a7 | Version Fixed In: | |
Sentry Crash Report: |
Description
qewer
2021-12-26 21:13:28 UTC
Hi, thanks for the report. The backtrace is useless, but seeing that you are on Arch, maybe you can compile kate and get a better backtrace? You need to do the following in sequence: ``` git clone https://invent.kde.org/utilities/kate.git cd kate mkdir build && cd build cmake .. make -j8 QT_PLUGIN_PATH=./bin ./bin/kate ``` The above assumes that you have the following packages installed: - gcc - gdb - cmake - git Should take a few minutes. After the last command kate will open with plugins loaded from the "./bin" directory inside the "build" directory you created. Now open your project via "File -> Open Folder". Make it crash. Then ``` coredumpctl debug ``` once the above gives you a (gdb) prompt, type bt and copy paste the backtrace here. Failed to reproduce with typescript-language-server 0.8.1 on a small repo and kate from master branch. (In reply to Waqar Ahmed from comment #1) > Hi, thanks for the report. > > The backtrace is useless, but seeing that you are on Arch, maybe you can > compile kate and get a better backtrace? > > You need to do the following in sequence: > > ``` > git clone https://invent.kde.org/utilities/kate.git > cd kate > mkdir build && cd build > cmake .. > make -j8 > QT_PLUGIN_PATH=./bin ./bin/kate > ``` > > The above assumes that you have the following packages installed: > - gcc > - gdb > - cmake > - git > > Should take a few minutes. After the last command kate will open with > plugins loaded from the "./bin" directory inside the "build" directory you > created. Now open your project via "File -> Open Folder". Make it crash. Then > > ``` > coredumpctl debug > ``` > > once the above gives you a (gdb) prompt, type > > bt > > and copy paste the backtrace here. I followed the instructions, this is the ourput backtrace: ``` #0 0x00007f95a59a4d22 in raise () from /usr/lib/libc.so.6 #1 0x00007f95a7653540 in KCrash::defaultCrashHandler(int) () from /usr/lib/libKF5Crash.so.5 #2 <signal handler called> #3 0x00007f95a59a4d22 in raise () from /usr/lib/libc.so.6 #4 0x00007f95a598e862 in abort () from /usr/lib/libc.so.6 #5 0x00007f95a5d2c802 in __gnu_cxx::__verbose_terminate_handler () at /build/gcc/src/gcc/libstdc++-v3/libsupc++/vterminate.cc:95 #6 0x00007f95a5d38c8a in __cxxabiv1::__terminate (handler=<optimized out>) at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:48 #7 0x00007f95a5d38cf7 in std::terminate () at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:58 #8 0x00007f95a5d38f8e in __cxxabiv1::__cxa_throw (obj=<optimized out>, tinfo=0x7f95a5e9b208 <typeinfo for std::out_of_range>, dest=0x7f95a5d4f010 <std::out_of_range::~out_of_range()>) at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_throw.cc:95 #9 0x00007f95a5d2f514 in std::__throw_out_of_range_fmt (__fmt=<optimized out>) at /build/gcc/src/gcc/libstdc++-v3/src/c++11/functexcept.cc:100 #10 0x00007f9593ee6559 in std::vector<QExplicitlySharedDataPointer<KTextEditor::Attribute>, std::allocator<QExplicitlySharedDataPointer<KTextEditor::Attribute> > >::_M_range_check (this=0x55f99a28ab20, __n=18446744073709551615) at /usr/include/c++/11.1.0/bits/stl_vector.h:1073 #11 0x00007f9593ee5969 in std::vector<QExplicitlySharedDataPointer<KTextEditor::Attribute>, std::allocator<QExplicitlySharedDataPointer<KTextEditor::Attribute> > >::at ( this=0x55f99a28ab20, __n=18446744073709551615) at /usr/include/c++/11.1.0/bits/stl_vector.h:1112 #12 0x00007f9593ee5779 in SemanticTokensLegend::attributeForTokenType (this=0x55f99a28ab08, idx=-1) at /home/qewer33/Desktop/Git/kate/addons/lspclient/semantic_tokens_legend.h:59 #13 0x00007f9593ee4cc0 in SemanticHighlighter::highlight (this=0x55f999d7b998, view=0x55f999d72010, legend=0x55f99a28ab08) at /home/qewer33/Desktop/Git/kate/addons/lspclient/lspsemantichighlighting.cpp:212 #14 0x00007f9593ee4607 in SemanticHighlighter::processTokens (this=0x55f999d7b998, tokens=..., view=0x55f999d72010, legend=0x55f99a28ab08) at /home/qewer33/Desktop/Git/kate/addons/lspclient/lspsemantichighlighting.cpp:129 #15 0x00007f9593ee3cc7 in operator() (__closure=0x55f99969d120, st=...) at /home/qewer33/Desktop/Git/kate/addons/lspclient/lspsemantichighlighting.cpp:90 #16 0x00007f9593ee562b in std::__invoke_impl<void, SemanticHighlighter::doSemanticHighlighting_impl(KTextEditor::View*)::<lambda(const LSPSemanticTokensDelta&)>&, const LSPSemanticTokensDelta&>(std::__invoke_other, struct {...} &) (__f=...) at /usr/include/c++/11.1.0/bits/invoke.h:61 #17 0x00007f9593ee54e4 in std::__invoke_r<void, SemanticHighlighter::doSemanticHighlighting_impl(KTextEditor::View*)::<lambda(const LSPSemanticTokensDelta&)>&, const LSPSemanticTokensDelta&>(struct {...} &) (__fn=...) at /usr/include/c++/11.1.0/bits/invoke.h:111 #18 0x00007f9593ee52d9 in std::_Function_handler<void(const LSPSemanticTokensDelta&), SemanticHighlighter::doSemanticHighlighting_impl(KTextEditor::View*)::<lambda(const LSPSemanticTokensDelta&)> >::_M_invoke(const std::_Any_data &, const LSPSemanticTokensDelta &) (__functor=..., __args#0=...) at /usr/include/c++/11.1.0/bits/std_function.h:291 #19 0x00007f9593eb76ab in std::function<void (LSPSemanticTokensDelta const&)>::operator()(LSPSemanticTokensDelta const&) const (this=0x55f99a063f50, __args#0=...) at /usr/include/c++/11.1.0/bits/std_function.h:560 #20 0x00007f9593e9dd0e in operator() (__closure=0x55f99a063f40, m=...) at /home/qewer33/Desktop/Git/kate/addons/lspclient/lspclientserver.cpp:1603 #21 0x00007f9593ea2eb9 in std::__invoke_impl<void, make_handler<LSPSemanticTokensDelta>(ReplyHandler<LSPSemanticTokensDelta>&, const QObject*, utils::identity<std::function<LSPSemanticTokensDelta(const QJsonValue&)> >::type)::<lambda(const GenericReplyType&)>&, const QJsonValue&>(std::__invoke_other, struct {...} &) (__f=...) at /usr/include/c++/11.1.0/bits/invoke.h:61 #22 0x00007f9593ea1745 in std::__invoke_r<void, make_handler<LSPSemanticTokensDelta>(ReplyHandler<LSPSemanticTokensDelta>&, const QObject*, utils::identity<std::function<LSPSemanticTokensDelta(const QJsonValue&)> >::type)::<lambda(const GenericReplyType&)>&, const QJsonValue&>(struct {...} &) (__fn=...) at /usr/include/c++/11.1.0/bits/invoke.h:111 #23 0x00007f9593e9fad2 in std::_Function_handler<void(const QJsonValue&), make_handler<LSPSemanticTokensDelta>(ReplyHandler<LSPSemanticTokensDelta>&, const QObject*, utils::identity<std::function<LSPSemanticTokensDelta(const QJsonValue&)> >::type)::<lambda(const GenericReplyType&)> >::_M_invoke(const std::_Any_data &, const QJsonValue &) ( __functor=..., __args#0=...) at /usr/include/c++/11.1.0/bits/std_function.h:291 #24 0x00007f9593eb022b in std::function<void (QJsonValue const&)>::operator()(QJsonValue const&) const (this=0x7ffe745eafa0, __args#0=...) ``` Git commit 6193824fbb2fd0d4a3ae829ee258c9d3268829cf by Waqar Ahmed. Committed on 28/12/2021 at 10:20. Pushed by waqar into branch 'master'. SemanticTokens: Use size_t as argument for type Should fix the case of idx = -1 being rightfully out of bounds. M +2 -2 addons/lspclient/semantic_tokens_legend.h https://invent.kde.org/utilities/kate/commit/6193824fbb2fd0d4a3ae829ee258c9d3268829cf Thanks once again. Can you try with latest master and confirm if it fixes the crash? (In reply to Waqar Ahmed from comment #5) > Thanks once again. > > Can you try with latest master and confirm if it fixes the crash? Yep, can confirm it doesn't crash anymore. Thanks for the quick fix! Thanks, will backport to 21.12 soon. Also, if the repo that you are working on is open source, then it would be good to fix this in the server itself (assuming the real bug is there). So if you want, you can report it here: https://github.com/typescript-language-server/typescript-language-server . That's the repo of the language server you are using. And since I was one of the persons behind the semantic tokens feature in that server, I will try to look into it from the server's side too. The bug is basically that "type" in SemanticToken is -1, and hence leads to => array[-1] == out of bound == crash. Git commit 87aff4f47f079d32aa286f074cb0ecce8b1304a7 by Waqar Ahmed. Committed on 28/12/2021 at 12:45. Pushed by waqar into branch 'release/21.12'. SemanticTokens: Use size_t as argument for type Should fix the case of idx = -1 being rightfully out of bounds. (cherry picked from commit 6193824fbb2fd0d4a3ae829ee258c9d3268829cf) M +2 -2 addons/lspclient/semantic_tokens_legend.h https://invent.kde.org/utilities/kate/commit/87aff4f47f079d32aa286f074cb0ecce8b1304a7 |