Bug 438976 - Clazy crashes when parsing Qt 6.1.0 <QtTest> with old-style-connect check enabled
Summary: Clazy crashes when parsing Qt 6.1.0 <QtTest> with old-style-connect check ena...
Status: RESOLVED FIXED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources macOS
: NOR crash
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-21 05:44 UTC by ts826848+kde
Modified: 2021-06-30 23:29 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
stderr from crash (10.30 KB, text/plain)
2021-06-21 05:44 UTC, ts826848+kde
Details
Preprocessed LLVM 11 test.cpp (2.72 MB, application/octet-stream)
2021-06-30 00:12 UTC, ts826848+kde
Details
LLVM 11 test.sh crash reproducer (2.88 KB, text/plain)
2021-06-30 00:12 UTC, ts826848+kde
Details
Preprocessed LLVM 12 test.cpp (3.58 MB, application/zip)
2021-06-30 01:13 UTC, ts826848+kde
Details
LLVM 12 test.cpp crash reproducer (3.05 KB, application/x-sh)
2021-06-30 01:13 UTC, ts826848+kde
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ts826848+kde 2021-06-21 05:44:40 UTC
Created attachment 139560 [details]
stderr from crash

SUMMARY

Clazy v1.9 compiled against LLVM/Clang 11.1.0 segfaults when parsing <QtTest> from Qt 6.1.0 with old-style-connect check enabled

STEPS TO REPRODUCE

1. Install llvm@11 and qt (currently Qt 6.1.0) from Homebrew
2. Check out tag v1.9 from clazy repo
3. Compile/install clazy using CXX=/usr/local/opt/llvm@11/bin/clang++ and LLVM_ROOT=/usr/local/opt/llvm@11
4. $ export CLANGXX=/usr/local/opt/llvm@11/bin/clang++
5. $ cd /tmp
6. $ echo "#include <QtTest>" > test.cpp
7. $ clazy -std=c++17 -iframework /usr/local/lib -isystem /usr/local/opt/qt/Frameworks/QtTest.framework/Headers -Xclang -plugin-arg-clazy -Xclang  old-style-connect -c test.cpp

OBSERVED RESULT

Clang segfaults; stderr in attachment.

EXPECTED RESULT

Clang successfully compiles test.cpp

SOFTWARE/OS VERSIONS
macOS: 10.15.7
Qt Version: 6.1.0
Comment 1 Sergio Martins 2021-06-21 18:19:45 UTC
can't repro on Linux/llvm-12
Comment 2 ts826848+kde 2021-06-30 00:12:27 UTC
Created attachment 139753 [details]
Preprocessed LLVM 11 test.cpp
Comment 3 ts826848+kde 2021-06-30 00:12:59 UTC
Created attachment 139754 [details]
LLVM 11 test.sh crash reproducer
Comment 4 ts826848+kde 2021-06-30 01:13:01 UTC
I appear to get the same crash with LLVM 12.0.0 from Homebrew if I build either tag v1.9 + a29528ec87474a28258e34e7556fb38c5ba34a96 (Fix build with Clang 12) cherry-picked on top or the tip of the 1.9 branch.

I've attached preprocessed .cpp and .sh files from both LLVM 11 and 12.
Comment 5 ts826848+kde 2021-06-30 01:13:28 UTC
Created attachment 139755 [details]
Preprocessed LLVM 12 test.cpp
Comment 6 ts826848+kde 2021-06-30 01:13:50 UTC
Created attachment 139756 [details]
LLVM 12 test.cpp crash reproducer
Comment 7 Sergio Martins 2021-06-30 22:50:38 UTC
I've reproduced on macOS
Comment 8 Sergio Martins 2021-06-30 23:19:19 UTC
Git commit 19f1254224b69cffd639b4a343866e7db2a469df by Sergio Martins.
Committed on 30/06/2021 at 23:17.
Pushed by smartins into branch 'master'.

old-style-connect: Simplify regexp, which also fixes a crash

Simplification done by Jonathan Marten.

I don't understand why it fixes the crash though, but at least
it's not worse.
Related: bug 435615

M  +1    -1    src/checks/level2/old-style-connect.cpp

https://invent.kde.org/sdk/clazy/commit/19f1254224b69cffd639b4a343866e7db2a469df
Comment 9 ts826848+kde 2021-06-30 23:29:54 UTC
Thank you for the quick fix!