Bug 474743 - Crash on C++11-style struct initializer on template class?
Summary: Crash on C++11-style struct initializer on template class?
Status: REPORTED
Alias: None
Product: kdevelop
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR crash
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords: drkonqi
Depends on:
Blocks:
 
Reported: 2023-09-20 19:46 UTC by Daniel Santos
Modified: 2023-09-21 11:06 UTC (History)
1 user (show)

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


Attachments
New crash information added by DrKonqi (125.96 KB, text/plain)
2023-09-20 19:46 UTC, Daniel Santos
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Santos 2023-09-20 19:46:55 UTC
Application: kdevelop (5.10.221200 (22.12.0))
 (Compiled from sources)
Qt Version: 5.15.8
Frameworks Version: 5.102.0
Operating System: Linux 5.15.80-gentoo x86_64
Windowing System: X11
Distribution: "Gentoo Linux"
DrKonqi: 5.26.5 [KCrashBackend]

-- Information about the crash:
I was running with `KDEV_CLANG_DISPLAY_DIAGS=1 CLEAR_DUCHAIN_DIR=1 kdevelop`, but I sadly saw no output prior to the crash. I was about to add a template class and it crashed after I typed `template<typename T>` and which applied to the class below, as I hadn't had a chance to type the new class yet.

struct field : public blobmsg_policy {
    ptrdiff_t off;
    field(const char *name, enum blobmsg_type type, ptrdiff_t off)
	: blobmsg_policy{.name = name, .type = type}
        , off(off)
    {}
    virtual ~field();

    int read(void *dest, struct blob_attr *tb) const;
    int write(const void *src, struct blob_attr *tb)  const;
};

The crash can be reproduced every time.

-- Backtrace (Reduced):
#6  0x00007fc25e4f68ed in clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (this=0x7fc1fd4306c0, T=<optimized out>) at /usr/src/debug/sys-devel/clang-15.0.7-r1/clang/lib/AST/ASTContext.cpp:2394
#7  0x00007fc25e4ebab2 in clang::ASTContext::getTypeInfo(clang::Type const*) const (this=0x7fc1fd4306c0, T=<optimized out>) at /usr/src/debug/sys-devel/clang-15.0.7-r1/clang/lib/AST/ASTContext.cpp:1934
#8  0x00007fc25e4f7f0b in clang::ASTContext::getTypeInfoInChars(clang::Type const*) const (T=0x7fc1fd3b4440, this=0x7fc1fd4306c0) at /usr/src/debug/sys-devel/clang-15.0.7-r1/clang/lib/AST/ASTContext.cpp:1886
#9  clang::ASTContext::getTypeInfoInChars(clang::Type const*) const (this=0x7fc1fd4306c0, T=0x7fc1fd3b4440) at /usr/src/debug/sys-devel/clang-15.0.7-r1/clang/lib/AST/ASTContext.cpp:1883
#10 0x00007fc25e4f7e82 in clang::ASTContext::getTypeInfoInChars(clang::QualType) const (T=..., this=0x7fc1fd4306c0) at /usr/src/debug/sys-devel/clang-15.0.7-r1/clang/lib/AST/ASTContext.cpp:1892


Reported using DrKonqi
Comment 1 Daniel Santos 2023-09-20 19:46:57 UTC
Created attachment 161758 [details]
New crash information added by DrKonqi

DrKonqi auto-attaching complete backtrace.
Comment 2 Daniel Santos 2023-09-20 20:00:38 UTC
I had recently changed my Plasma appearance, but this looks like clang. I obtained my compiler settings by running:

/path/to/my/toolchain/mipsel-openwrt-linux-musl-g++ -fno-caller-saves -mips32r2 -mtune=24kc -msoft-float -mno-branch-likely -mips16 -minterlink-mips16 -E -x c++ -v - </dev/null

And these are the C++ compiler settings I'm using in the project config --> Language Support --> C/C++ Parser --> C++ command line args (prettied up for readability):

-std=gnu++17
--target=mipsel-openwrt-linux
-mabi=32
-msoft-float
-march=mips32r2
-mtune=24kc
-ferror-limit=100
-fspell-checking
-Wdocumentation
-Wunused-parameter
-Wunreachable-code
-Wall
-Wno-unknown-warning-option
-Wno-implicit-fallthrough
-nostdinc
-nostdinc++
-isystem /home/daniel/proj/embedded/openwrt/v21.02.y/staging_dir/toolchain-mipsel_24kc_gcc-10.2.0_musl/mipsel-openwrt-linux-musl/include/c++/10.2.0
-isystem /home/daniel/proj/embedded/openwrt/v21.02.y/staging_dir/toolchain-mipsel_24kc_gcc-10.2.0_musl/mipsel-openwrt-linux-musl/include/c++/10.2.0/mipsel-openwrt-linux-musl
-isystem /home/daniel/proj/embedded/openwrt/v21.02.y/staging_dir/toolchain-mipsel_24kc_gcc-10.2.0_musl/mipsel-openwrt-linux-musl/include/c++/10.2.0/backward
-isystem /home/daniel/proj/embedded/openwrt/v21.02.y/staging_dir/toolchain-mipsel_24kc_gcc-10.2.0_musl/include
-isystem /home/daniel/proj/embedded/openwrt/v21.02.y/staging_dir/toolchain-mipsel_24kc_gcc-10.2.0_musl/mipsel-openwrt-linux-musl/include
-isystem /home/daniel/proj/embedded/openwrt/v21.02.y/staging_dir/toolchain-mipsel_24kc_gcc-10.2.0_musl/lib/gcc/mipsel-openwrt-linux-musl/10.2.0/include
-isystem /home/daniel/proj/embedded/openwrt/project/libubox
-isystem /home/daniel/proj/embedded/openwrt/project/ubus
-isystem /home/daniel/proj/embedded/openwrt/v21.02.y/staging_dir/target-mipsel_24kc_musl/usr/include
-I.
Comment 3 Igor Kushnir 2023-09-21 11:06:17 UTC
Cannot reproduce with libclang version 16.0.6, but maybe my configuration differs in other ways. The backtrace suggests that this is a libclang bug. Could you try to compile the crashing snippet (with `template<typename T>`) by Clang and see if it crashes too?

If the crash is reproducible on your system, you can print some info about the crashing type. For example, insert the following line in two places: before the clang_Type_getSizeOf() call in builder.cpp and a few lines above - before the line `type = clang_getCanonicalType(type);` (replace the string literal with "Before clang_getCanonicalType()" on the higher-inserted line).
    qCritical() << "Before getSizeOf()" << type.kind << ClangString(clang_getTypeSpelling(type)).toString();