Bug 409596 - Adding a lambda as a template argument in a header where the template parameter is a function pointer type causes a crash.
Summary: Adding a lambda as a template argument in a header where the template paramet...
Status: RESOLVED WORKSFORME
Alias: None
Product: kdevelop
Classification: Applications
Component: Code completion (show other bugs)
Version: git master
Platform: Manjaro Linux
: NOR crash
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-07 19:25 UTC by Matti
Modified: 2022-10-24 05:00 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:
mattibryce: corner_case+


Attachments
File attempting to produce a reduced form of the bug (failed) (796 bytes, text/x-c++src)
2019-07-07 19:25 UTC, Matti
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matti 2019-07-07 19:25:17 UTC
Created attachment 121371 [details]
File attempting to produce a reduced form of the bug (failed)

SUMMARY
Adding a lambda as a template argument in a specific project (of mine) causes a crash when trying to parse a file.

STEPS TO REPRODUCE
1. Download the project via `git clone https://gitlab.com/TheEdenCrazy/correlative-neural-network.git`, `git checkout e8861a831819b858f9792570b8aebe9b2641b06b`
2. Open in kdevelop, making sure to set the C++ parser to C++17 (I don't know if the bug is c++-version-dependent but this should replicate it).
3. Add `_impl_add_t<&neuron_index::idx, [](){}> v;` to the file at "correlative-neural-network/library/include/cnn/storeprotodef/field_encode_gen.hpp", as a member of the template struct `_impl_FieldEncodingGenerator`, after the templates. 

OBSERVED RESULT
KDevelop crashes with a segfault after producing the following on the console:
 QProcess: Destroyed while process ("clang") is still running.
 kdevplatform.shell: process finished with error: QProcess::Crashed
 QProcess: Destroyed while process ("clang") is still running.
 kdevplatform.shell: process finished with error: QProcess::Crashed
 kdevelop.plugins.clang: Unhandled type: Dependent <dependent type>
 kdevelop.plugins.clang: Unhandled type: Dependent <dependent type>
 kdevelop.plugins.clang: Unhandled type: Dependent <dependent type>
 kdevelop.plugins.clang: Unhandled type: Dependent <dependent type>
 kdevelop.plugins.clang: Unhandled type: Dependent <dependent type>
 kdevelop.plugins.clang: Unhandled type: Dependent <dependent type>

EXPECTED RESULT
KDevelop does not crash, and (depending on the C++ version) there is either a syntax error or no syntax error (C++20 allows lambdas as function template arguments).


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Manjaro (latest update)
(available in About System)
KDE Plasma Version: [using xfce4-gtk3]
KDE Frameworks Version: KDevelop 5.3.2 and KDevelop as built from master.
Qt Version: 5.12.4

ADDITIONAL INFORMATION
I downloaded the Kdevelop project and built it and examined it in a debugger. As far as I can tell, the issue is related to the parser not recognising the type as one of those processed in kdevelop/plugins/clang, builder.cpp, Visitor::makeType.

I have attempted to replicate the bug by simply copy-pasting the core type structure (i.e. type-template in template in 2 namespaces), but it does not work. However, I cannot replicate it and it produces the expected behaviour. See the file I used for testing attached.
Comment 1 Matti 2019-07-08 04:51:37 UTC
I'm working on reducing down the project to the files that generate the crash. Do: `git clone https://gitlab.com/TheEdenCrazy/cnn_kdevbug_reduce.git` and it should reproduce the bug. Also see the branches for what didn't remove the bug.
Comment 2 Matti 2019-07-08 18:48:05 UTC
I have reduced the bug down to just a header and a main.cpp (which just imports the header). Directly pasting the header into main.cpp does not reproduce the bug. See the reduced-code repo to see exactly what code is triggering the crash.
Comment 3 Matti 2019-07-08 21:59:10 UTC
Adding `std::cout << "Visiting cursor\n";` to the Visitor::dispatchCursor method shows that that part of code isn't even touched before the crash.
Comment 4 Matti 2019-08-26 00:10:18 UTC
My sincere apologies! I only just realised that the repo I linked was private!


You should be able to access it now.
Comment 5 Justin Zobel 2022-09-24 09:52:35 UTC
Thank you for reporting this crash in KDE software. As it has been a while since this issue was reported, can we please ask you to see if you can reproduce the crash with a recent software version?

If you can reproduce the issue, please change the status to "CONFIRMED" when replying. Thank you!
Comment 6 Bug Janitor Service 2022-10-09 04:51:47 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 7 Bug Janitor Service 2022-10-24 05:00:20 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!