https://bugs.kde.org/show_bug.cgi?id=434867

            Bug ID: 434867
           Summary: Crashes in clang when typing int strncpy()
           Product: kdevelop
           Version: 5.6.2
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: Analyzer: Clang-Tidy
          Assignee: kdevelop-bugs-n...@kde.org
          Reporter: aar...@doofus.org
                CC: kosse...@kde.org
  Target Milestone: ---

SUMMARY

Typed int strncpy() and it crashed.  When I restarted KDevelop and attempted to
restore the file it also crashed immediately.  Since I needed to move on, I
wrote the function prototype elsewhere and copied and pasted it and it worked.
I know that strncpy() is not supposed to return an int.  I was doing a quick
implementation from memory for a large embedded project that doesn't support it
(and it's a well-known service that includes security!).

I tried typing it in another project but could not reproduce it.

OBSERVED RESULT
0x00007fffa8d51325 in
clang::Sema::checkFortifiedBuiltinMemoryFunction(clang::FunctionDecl*,
clang::CallExpr*) () from /usr/lib64/../lib64/libclang-cpp.so.9
(gdb) bt
#0  0x00007fffa8d51325 in
clang::Sema::checkFortifiedBuiltinMemoryFunction(clang::FunctionDecl*,
clang::CallExpr*) () from /usr/lib64/../lib64/libclang-cpp.so.9
#1  0x00007fffa904a2ee in clang::Sema::BuildResolvedCallExpr(clang::Expr*,
clang::NamedDecl*, clang::SourceLocation, llvm::ArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*, bool, clang::CallExpr::ADLCallKind) ()
from /usr/lib64/../lib64/libclang-cpp.so.9
#2  0x00007fffa902f68f in clang::Sema::BuildCallExpr(clang::Scope*,
clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*, bool) ()
   from /usr/lib64/../lib64/libclang-cpp.so.9
#3  0x00007fffa90486e8 in clang::Sema::ActOnCallExpr(clang::Scope*,
clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*) ()
   from /usr/lib64/../lib64/libclang-cpp.so.9
#4  0x00007fffa8725ab4 in
clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*,
true>) () from /usr/lib64/../lib64/libclang-cpp.so.9
#5  0x00007fffa8728ce7 in clang::Parser::ParseCastExpression(bool, bool, bool&,
clang::Parser::TypeCastState, bool) () from
/usr/lib64/../lib64/libclang-cpp.so.9
#6  0x00007fffa87231b6 in
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) ()
   from /usr/lib64/../lib64/libclang-cpp.so.9
#7  0x00007fffa877a623 in
clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) ()
   from /usr/lib64/../lib64/libclang-cpp.so.9
#8  0x00007fffa87784b9 in
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&) () from
/usr/lib64/../lib64/libclang-cpp.so.9
#9  0x00007fffa8777f8b in
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) () from
/usr/lib64/../lib64/libclang-cpp.so.9
#10 0x00007fffa8781e33 in clang::Parser::ParseCompoundStatementBody(bool) ()
   from /usr/lib64/../lib64/libclang-cpp.so.9
#11 0x00007fffa87786ea in
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&) () from
/usr/lib64/../lib64/libclang-cpp.so.9
#12 0x00007fffa8777f8b in
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) () from
/usr/lib64/../lib64/libclang-cpp.so.9
#13 0x00007fffa877c4ba in
clang::Parser::ParseIfStatement(clang::SourceLocation*) ()
   from /usr/lib64/../lib64/libclang-cpp.so.9
#14 0x00007fffa87788eb in
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&) () from
/usr/lib64/../lib64/libclang-cpp.so.9
#15 0x00007fffa8777f8b in
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) () from
/usr/lib64/../lib64/libclang-cpp.so.9
#16 0x00007fffa8781e33 in clang::Parser::ParseCompoundStatementBody(bool) ()
   from /usr/lib64/../lib64/libclang-cpp.so.9
#17 0x00007fffa87786ea in
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&) () from
/usr/lib64/../lib64/libclang-cpp.so.9
#18 0x00007fffa8777f8b in
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) () from
/usr/lib64/../lib64/libclang-cpp.so.9
#19 0x00007fffa877c4ba in
clang::Parser::ParseIfStatement(clang::SourceLocation*) ()
   from /usr/lib64/../lib64/libclang-cpp.so.9
--Type <RET> for more, q to quit, c to continue without paging--c
#20 0x00007fffa87788eb in
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&) () from
/usr/lib64/../lib64/libclang-cpp.so.9
#21 0x00007fffa8777f8b in
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) () from
/usr/lib64/../lib64/libclang-cpp.so.9
#22 0x00007fffa8781e33 in clang::Parser::ParseCompoundStatementBody(bool) ()
from /usr/lib64/../lib64/libclang-cpp.so.9
#23 0x00007fffa87830d8 in
clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) () from /usr/lib64/../lib64/libclang-cpp.so.9
#24 0x00007fffa879f8cb in
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
() from /usr/lib64/../lib64/libclang-cpp.so.9
#25 0x00007fffa86f3373 in
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
() from /usr/lib64/../lib64/libclang-cpp.so.9
#26 0x00007fffa879e5b7 in
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier) () from
/usr/lib64/../lib64/libclang-cpp.so.9
#27 0x00007fffa879def4 in
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) () from
/usr/lib64/../lib64/libclang-cpp.so.9
#28 0x00007fffa879ccfc in
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) () from /usr/lib64/../lib64/libclang-cpp.so.9
#29 0x00007fffa879a8cd in
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
() from /usr/lib64/../lib64/libclang-cpp.so.9
#30 0x00007fffa86daaad in clang::ParseAST(clang::Sema&, bool, bool) () from
/usr/lib64/../lib64/libclang-cpp.so.9
#31 0x00007fffa9fa8074 in clang::FrontendAction::Execute() () from
/usr/lib64/../lib64/libclang-cpp.so.9
#32 0x00007fffa9f4b141 in
clang::ASTUnit::Parse(std::shared_ptr<clang::PCHContainerOperations>,
std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) () from
/usr/lib64/../lib64/libclang-cpp.so.9
#33 0x00007fffa9f51f47 in
clang::ASTUnit::Reparse(std::shared_ptr<clang::PCHContainerOperations>,
llvm::ArrayRef<std::pair<std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> >, llvm::MemoryBuffer*> >,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) () from
/usr/lib64/../lib64/libclang-cpp.so.9
#34 0x00007fffaabd8857 in ?? () from /usr/lib64/libclang.so.9
#35 0x00007fffa3e7580c in
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) () from
/usr/lib64/../lib64/libLLVM.so.9
#36 0x00007fffa3e75914 in ?? () from /usr/lib64/../lib64/libLLVM.so.9
#37 0x00007fffa3f43b7a in ?? () from /usr/lib64/../lib64/libLLVM.so.9
#38 0x00007fffece7b4f9 in start_thread (arg=0x7fff98d9a700) at
pthread_create.c:465
#39 0x00007ffff41d6ecf in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:95

EXPECTED RESULT
I expect it not to crash.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 5.80.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
libclang9-9.0.1

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to