-
Notifications
You must be signed in to change notification settings - Fork 12.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clang-tidy segfault #101323
Comments
Added llvm-symbolizer to path:
#0 0x0000000003ab4418 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/local/clang-18/bin/clang-tidy+0x3ab4418) |
Function on which it happens (code is bad, but...) void DynamicAddressResolver::onReadFromTesla(const AddressResolveFromTesla& resolved)
{
std::unique_lock lock{tasksMutex_};
auto* plugin{pluginP_->plugin_};
plugin->log(DGateBaseAPI::LogDebug,
"Processing new address resolve result '%d'",
resolved.description.index());
switch (static_cast<AddressResolveFromTesla::Type>(resolved.description.index()))
{
case AddressResolveFromTesla::RouteToDgate: {
plugin->log(DGateBaseAPI::LogDebug, "Got route to dgate");
const auto& toDgate{std::get<RouteToDgateInfo>(resolved.description)};
const auto& route{toDgate.route};
if (!route.hasFrom)
{
plugin->log(DGateBaseAPI::LogDebug, "No source for msg to dgate, skipping");
if (messagesFromSocketByUniqueNumber_.count(toDgate.originalUniqueNumber) != 0)
{
messagesFromSocketByUniqueNumber_.erase(toDgate.originalUniqueNumber);
}
return;
}
auto from{route.from};
auto to{route.to};
auto msg{std::move(messagesFromSocketByUniqueNumber_.at(toDgate.originalUniqueNumber))};
messagesFromSocketByUniqueNumber_.erase(toDgate.originalUniqueNumber);
if (to.empty())
{
plugin->log(DGateBaseAPI::LogDebug, "Got message without destination, skipping");
return;
}
std::string_view msgBody{msg->body()};
std::string cuttedMsg{msgBody.substr(0, std::min<size_t>(80, msgBody.size()))};
plugin->log(DGateKernelAPI::LogDebug,
"Message '%s' is accepted to processing",
cuttedMsg.data());
// TODO() ref make it smaller
taskQueue_.emplace(
[this,
from = std::move(from),
to = std::move(to),
dgateMsg = msg.release(), // because function must be copyable
cuttedMsg = std::move(cuttedMsg),
plugin]() mutable -> void {
using FullyAccessibleDgateMessage = tesla_dgate::FullyAccessibleDgateMessage;
plugin->log(DGateKernelAPI::LogDebug,
"Start processing msg '%s'",
cuttedMsg.data());
auto remoteAddress{endpointToDgateAddr(from)};
SocketMessage message(
pluginP_,
std::unique_ptr<FullyAccessibleDgateMessage>(dgateMsg),
remoteAddress,
endpointToDgateAddr(pluginP_->localAddress_, pluginP_->localPort_));
gsl::owner<DGateAddress**> addresses{new DGateAddress*[to.size()]};
for (std::size_t i{0}; i < to.size(); ++i)
{
// NOLINTNEXTLINE
addresses[i] = new SocketAddress(endpointToDgateAddr(to[i]).c_str());
}
message.setTo(addresses, static_cast<int>(to.size()));
int id = plugin->saveMessage(&message);
if (id == 0)
{
plugin->log(DGateKernelAPI::LogErr,
"Error while saving message '%s'",
cuttedMsg.data());
return;
}
if (!plugin->sendMessage(id))
{
plugin->log(DGateKernelAPI::LogErr,
"Error while sending message '%s'",
cuttedMsg.data());
return;
}
});
tasksCv_.notify_all();
}
break;
case AddressResolveFromTesla::RouteToSocket: {
plugin->log(DGateBaseAPI::LogDebug, "Got route to socket");
const auto& toSocket{std::get<RouteToSocketInfo>(resolved.description)};
const auto& route{toSocket.route};
SocketInfo from = route.hasFrom ? route.from : SocketInfo{};
auto msg{std::move(messagesFromDgateByUniqueNumber_.at(toSocket.originalUniqueNumber))};
messagesFromDgateByUniqueNumber_.erase(toSocket.originalUniqueNumber);
if (!route.hasFrom || from.ip != pluginP_->localAddress_ ||
from.port != pluginP_->localPort_)
{ // send as client
std::shared_ptr<DGateMessage> msgShared{msg.get()};
for (const auto& to: route.to)
{
SocketPair socketPair{.local = from, .remote = to};
if (clientsByConnection_.count(socketPair) == 0)
{
auto client{std::make_unique<SocketClient>(
this,
pluginP_,
socketPair.local.ip,
socketPair.local.port,
socketPair.remote.ip,
socketPair.remote.port)};
client->startThread();
socketPair.local.port = client->getLocalPort();
clientsByConnection_[socketPair] = std::move(client);
}
if (!clientsByConnection_[socketPair]->waitToConnect())
{
taskQueue_.emplace([plugin, msg]() {
plugin->setMessageProcessingStatus(
msg->dgateId(), DGateKernelAPI::ProcessingError);
delete msg;
int len{0};
plugin->log(DGateBaseAPI::LogDebug,
"error while sending message %s: can't connect to remote "
"socket",
msg->nativeId(len));
});
return;
}
clientsByConnection_[socketPair]->onMessageFromDgate(msgShared, true, {to});
}
} else // send as server
{
server_->onMessageFromDgate(std::move(msg), true, route.to);
}
// delete msg;
}
break;
}
} |
Could you test on Clang-tidy 19 ? |
I'll test within 24-48 hours probably. |
Clang-tidy still crashes(( clang-tidy --version Stacktrace seems to look the same, but just in case:
|
Also, changing this part (it is close to the end of the code snippet): taskQueue_.emplace([plugin, msg]() {
plugin->setMessageProcessingStatus(
msg->dgateId(), DGateKernelAPI::ProcessingError);
delete msg;
int len{0};
plugin->log(DGateBaseAPI::LogDebug,
"error while sending message %s: can't connect to remote "
"socket",
msg->nativeId(len));
}); To this: plugin->setMessageProcessingStatus(
msg->dgateId(), DGateKernelAPI::ProcessingError);
int len{0};
plugin->log(DGateBaseAPI::LogDebug,
"error while sending message %s: can't connect to remote "
"socket",
msg->nativeId(len)); P.S. 1. Here msg is taskQueue_.emplace([plugin, msg]() {
plugin->setMessageProcessingStatus(
msg->dgateId(), DGateKernelAPI::ProcessingError);
int len{0};
plugin->log(DGateBaseAPI::LogDebug,
"error while sending message %s: can't connect to remote "
"socket",
msg->nativeId(len));
}); |
Sorry, I can't send you a full code to reproduce the error / make some simplified version of it right now. |
Looks to be duplicate of #70460 |
[build] Error running 'clang-tidy': PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
[build] Stack dump:
[build] 0. Program arguments: clang-tidy --export-fixes=fixes.yaml --use-color -p= --extra-arg-before=--driver-mode=g++ /home/novak_share/repos/socket-dgate/src/plugin/dynamic_address_resolver.cpp -- /usr/local/bin/clang++ -DQT_CORE_LIB -Duniplugin_socket_EXPORTS -I/usr/local/udps/include -I/usr/local/metamanager/include -I/usr/local/ods/include -I/usr/local/ptconvert/include -I/usr/local/tesla/include -I/usr/local/seal/include -I/usr/local/base/include -I/usr/include/jsoncpp -I/usr/dgate/include -I/home/novak_share/repos/socket-dgate/src/plugin/net_part -I/home/novak_share/repos/socket-dgate/src/plugin/. -I/usr/include/x86_64-linux-gnu/qt5/QtXml -I/usr/include/x86_64-linux-gnu/qt5/QtXmlPatterns -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -I/home/novak_share/repos/socket-dgate/src/tesla-interface/include -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -isystem /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -g -std=gnu++17 -fPIC -Wall -Wextra -Wpedantic -Wswitch-enum -Wno-c++20-designator -I/usr/local/udps/include -I/usr/local/metamanager/include -I/usr/local/ods/include -I/usr/local/ptconvert/include -I/usr/local/tesla/include -I/usr/local/seal/include -I/usr/local/base/include -DPARSEC -D__UNICODE -D__UTF8 -D__STDC_FORMAT_MACROS -D__PGIFACE_VIRTUAL -I/usr/include/jsoncpp -I/usr/include -I/usr/dgate/include -DQT_XML_LIB -DQT_XMLPATTERNS_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I/usr/include/x86_64-linux-gnu/qt5/QtXml -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtXmlPatterns -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -I/usr/include/x86_64-linux-gnu/qt5/QtCore -fPIC -MD -MT src/plugin/CMakeFiles/uniplugin_socket.dir/dynamic_address_resolver.cpp.o -MF src/plugin/CMakeFiles/uniplugin_socket.dir/dynamic_address_resolver.cpp.o.d -o src/plugin/CMakeFiles/uniplugin_socket.dir/dynamic_address_resolver.cpp.o -c /home/novak_share/repos/socket-dgate/src/plugin/dynamic_address_resolver.cpp
[build] 1. parser at end of file
[build] 2. ASTMatcher: Matching 'cppcoreguidelines-owning-memory' against:
[build] CXXMethodDecl DynamicAddressResolver::onReadFromTesla : </home/novak_share/repos/socket-dgate/src/plugin/dynamic_address_resolver.cpp:390:1, line:532:1>
[build] Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var
LLVM_SYMBOLIZER_PATH
to point to it):[build] 0 clang-tidy 0x0000000003ab4418 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 40
[build] 1 clang-tidy 0x0000000003ab1c6c
[build] 2 libpthread.so.0 0x000075ec01c74730
[build] 3 clang-tidy 0x0000000002a8eef0 clang::ASTNodeKind::getFromNode(clang::Stmt const&) + 0
[build] 4 clang-tidy 0x000000000291634f
[build] 5 clang-tidy 0x0000000002918266
[build] 6 clang-tidy 0x00000000029197a8
[build] 7 clang-tidy 0x000000000291fabc
[build] 8 clang-tidy 0x0000000002916fab
[build] 9 clang-tidy 0x00000000029197a8
[build] 10 clang-tidy 0x000000000291f903
[build] 11 clang-tidy 0x000000000292cac8
[build] 12 clang-tidy 0x0000000002915069
[build] 13 clang-tidy 0x000000000292d326
[build] 14 clang-tidy 0x000000000292e178
[build] 15 clang-tidy 0x0000000000a92340
[build] 16 clang-tidy 0x000000000294b873 clang::ast_matchers::internal::DynTypedMatcher::matchesNoKindCheck(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const + 195
[build] 17 clang-tidy 0x000000000294ba1e
[build] 18 clang-tidy 0x000000000294c681
[build] 19 clang-tidy 0x000000000294bb21 clang::ast_matchers::internal::DynTypedMatcher::matches(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const + 209
[build] 20 clang-tidy 0x0000000000c46ac8
[build] 21 clang-tidy 0x000000000294bb21 clang::ast_matchers::internal::DynTypedMatcher::matches(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const + 209
[build] 22 clang-tidy 0x000000000290f7be
[build] 23 clang-tidy 0x0000000002930c7a
[build] 24 clang-tidy 0x00000000029315ea
[build] 25 clang-tidy 0x000000000294137d
[build] 26 clang-tidy 0x0000000002930c85
[build] 27 clang-tidy 0x0000000002930f11 clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) + 513
[build] 28 clang-tidy 0x0000000001a1d368 clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) + 40
[build] 29 clang-tidy 0x0000000001c63f91 clang::ParseAST(clang::Sema&, bool, bool) + 1105
[build] 30 clang-tidy 0x00000000019e7ed1 clang::FrontendAction::Execute() + 145
[build] 31 clang-tidy 0x000000000196a2da clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 298
[build] 32 clang-tidy 0x0000000001239c0e clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptrclang::CompilerInvocation, clang::FileManager*, std::shared_ptrclang::PCHContainerOperations, clang::DiagnosticConsumer*) + 302
[build] 33 clang-tidy 0x00000000011e8bf5
[build] 34 clang-tidy 0x0000000001233dd3 clang::tooling::ToolInvocation::run() + 1315
[build] 35 clang-tidy 0x00000000012376cd clang::tooling::ClangTool::run(clang::tooling::ToolAction*) + 3373
[build] 36 clang-tidy 0x00000000011f4845 clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits, std::allocator>>, llvm::IntrusiveRefCntPtrllvm::vfs::OverlayFileSystem, bool, bool, llvm::StringRef) + 965
[build] 37 clang-tidy 0x0000000000a1be01 clang::tidy::clangTidyMain(int, char const**) + 1905
[build] 38 libc.so.6 0x000075ec0177609b __libc_start_main + 235
[build] 39 clang-tidy 0x0000000000a138ca _start + 42
[build] Segmentation fault
Clang-tidy version:
LLVM (http://llvm.org/):
LLVM version 18.1.1
Optimized build.
System: proprietary linux based on Debian (I don't know version on which it is based). Kernel version: 5.15.0-70-generic.
The text was updated successfully, but these errors were encountered: