https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97372
Bug ID: 97372
Summary: Segmentation fault using Tracy 0.7.3 in template class
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: public at enkore dot de
Target Milestone: ---
Full reproducer attached:
$ g++ gcc_segfault_repro.ii
gcc_segfault_repro.cpp: In instantiation of ‘ThreadTask2<T>::ThreadTask2()
[with T = int]’:
gcc_segfault_repro.cpp:15:22: required from here
gcc_segfault_repro.cpp:7:135: internal compiler error: Segmentation fault
7 | TracyLockable(std::mutex, _state_mutex);
|
^
$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl
--with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit
--enable-cet=auto --enable-checking=release --enable-clocale=gnu
--enable-default-pie --enable-default-ssp --enable-gnu-indirect-function
--enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id
--enable-lto --enable-multilib --enable-plugin --enable-shared
--enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-libunwind-exceptions --disable-werror
gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC)
Offending code looks like this (using Tracy from
https://github.com/wolfpld/tracy):
#include <mutex>
#include <Tracy.hpp>
template<typename T>
class ThreadTask2 {
TracyLockable(std::mutex, _state_mutex);
public:
ThreadTask2() {
}
};
void x() {
ThreadTask2<int> foo;
}
When the template is removed from ThreadTask2, GCC stops segfaulting. In the
actual codebase GCC points out a slightly more specific source location, but
this may be an artifact and unrelated to the bug itself:
Tracy.hpp:141:159: internal compiler error: Segmentation fault
141 | #define TracyLockable( type, varname ) tracy::Lockable<type> varname {
[] () -> const tracy::SourceLocationData* { static constexpr
tracy::SourceLocationData srcloc { nullptr, #type " " #varname, __FILE__,
__LINE__, 0 }; return &srcloc; }() };
|
^~~~~~
common.h:76:13: note: in expansion of macro ‘TracyLockable’
76 | mutable TracyLockable(std::mutex, _state_mutex);
|