Skip to content
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

Crash happens when I use 'the scanset' in scanf (VSCode Extension) #1675

Closed
swkfk opened this issue Jun 18, 2023 · 3 comments
Closed

Crash happens when I use 'the scanset' in scanf (VSCode Extension) #1675

swkfk opened this issue Jun 18, 2023 · 3 comments

Comments

@swkfk
Copy link

swkfk commented Jun 18, 2023

The clangd will crash when I type the following code:

#include <stdio.h>

int main() {
    scanf("%512[\\]")
}

As soon as I put the \\ in the [], the crash will occure.

Logs

Part of the logs:

I[17:56:32.790] <-- textDocument/codeAction(1)
V[17:56:32.846] Driver produced command: cc1 -cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name broken.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/home/swkfk/data-struct/final -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/home/swkfk/data-struct/final -ferror-limit 19 -fgnuc-version=4.2.1 -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -x c /home/swkfk/data-struct/final/broken.c
I[17:56:32.846] --> textDocument/clangd.fileStatus
V[17:56:32.846] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"parsing includes, running Update (1)","uri":"file:///home/swkfk/data-struct/final/broken.c"}}

V[17:56:32.846] Building first preamble for /home/swkfk/data-struct/final/broken.c version 1
V[17:56:32.858] indexed preamble AST for /home/swkfk/data-struct/final/broken.c version 1:
symbol slab: 363 symbols, 104816 bytes
ref slab: 0 symbols, 0 refs, 128 bytes
relations slab: 0 relations, 24 bytes
V[17:56:32.861] Build dynamic index for header symbols with estimated memory usage of 539748 bytes
V[17:56:32.861] Built preamble of size 288608 for file /home/swkfk/data-struct/final/broken.c version 1
I[17:56:32.861] --> workspace/semanticTokens/refresh(0)
V[17:56:32.861] >>> {"id":0,"jsonrpc":"2.0","method":"workspace/semanticTokens/refresh","params":null}

I[17:56:32.861] --> textDocument/clangd.fileStatus
V[17:56:32.861] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"parsing includes, running Build AST","uri":"file:///home/swkfk/data-struct/final/broken.c"}}

I[17:56:32.861] --> textDocument/clangd.fileStatus
V[17:56:32.861] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"parsing includes, parsing main file","uri":"file:///home/swkfk/data-struct/final/broken.c"}}

V[17:56:32.862] <<< {"id":0,"jsonrpc":"2.0","result":null}

I[17:56:32.862] <-- reply(0)
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamEi+0x31)[0x7f01d1effd01]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm3sys17RunSignalHandlersEv+0xbc)[0x7f01d1efda0c]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(+0xe40236)[0x7f01d1f00236]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7f01d0ba7520]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZNK5clang4Expr21tryEvaluateObjectSizeERmRNS_10ASTContextEj+0x1e)[0x7f01d89b630e]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(+0x11a044d)[0x7f01d8e6d44d]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(+0x11df185)[0x7f01d8eac185]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(+0x11c8458)[0x7f01d8e95458]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang21analyze_format_string16ParseScanfStringERNS0_19FormatStringHandlerEPKcS4_RKNS_11LangOptionsERKNS_10TargetInfoE+0x658)[0x7f01d8b02458]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang4Sema35checkFortifiedBuiltinMemoryFunctionEPNS_12FunctionDeclEPNS_8CallExprE+0xaed)[0x7f01d8e6cf6d]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang4Sema21BuildResolvedCallExprEPNS_4ExprEPNS_9NamedDeclENS_14SourceLocationEN4llvm8ArrayRefIS2_EES5_S2_bNS_8CallExpr11ADLCallKindE+0xf71)[0x7f01d9093731]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang4Sema13BuildCallExprEPNS_5ScopeEPNS_4ExprENS_14SourceLocationEN4llvm15MutableArrayRefIS4_EES5_S4_bb+0xa6c)[0x7f01d907b1fc]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(ZN5clang4Sema13ActOnCallExprEPNS_5ScopeEPNS_4ExprENS_14SourceLocationEN4llvm15MutableArrayRefIS4_EES5_S4+0x47)[0x7f01d9091e47]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6Parser28ParsePostfixExpressionSuffixENS_12ActionResultIPNS_4ExprELb1EEE+0x18ab)[0x7f01d8717d3b]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6Parser19ParseCastExpressionENS0_13CastParseKindEbRbNS0_13TypeCastStateEbPb+0xd8)[0x7f01d8718908]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6Parser25ParseAssignmentExpressionENS0_13TypeCastStateE+0xe6)[0x7f01d8714936]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6Parser15ParseExpressionENS0_13TypeCastStateE+0x9)[0x7f01d8714839]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6Parser18ParseExprStatementENS0_17ParsedStmtContextE+0x46)[0x7f01d8771146]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6Parser42ParseStatementOrDeclarationAfterAttributesERN4llvm11SmallVectorIPNS_4StmtELj32EEENS0_17ParsedStmtContextEPNS_14SourceLocationERNS_25ParsedAttributesWithRangeE+0x1b5b)[0x7f01d8770c8b]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6Parser27ParseStatementOrDeclarationERN4llvm11SmallVectorIPNS_4StmtELj32EEENS0_17ParsedStmtContextEPNS_14SourceLocationE+0xcf)[0x7f01d876ef9f]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6Parser26ParseCompoundStatementBodyEb+0x771)[0x7f01d87778f1]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6Parser26ParseFunctionStatementBodyEPNS_4DeclERNS0_10ParseScopeE+0xb8)[0x7f01d8778818]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6Parser23ParseFunctionDefinitionERNS_17ParsingDeclaratorERKNS0_18ParsedTemplateInfoEPNS0_18LateParsedAttrListE+0xddf)[0x7f01d879259f]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6Parser14ParseDeclGroupERNS_15ParsingDeclSpecENS_17DeclaratorContextEPNS_14SourceLocationEPNS0_12ForRangeInitE+0x1210)[0x7f01d86eacc0]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6Parser30ParseDeclOrFunctionDefInternalERNS_25ParsedAttributesWithRangeERNS_15ParsingDeclSpecENS_15AccessSpecifierE+0x35b)[0x7f01d87915ab]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6Parser36ParseDeclarationOrFunctionDefinitionERNS_25ParsedAttributesWithRangeEPNS_15ParsingDeclSpecENS_15AccessSpecifierE+0x190)[0x7f01d8791060]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6Parser24ParseExternalDeclarationERNS_25ParsedAttributesWithRangeEPNS_15ParsingDeclSpecE+0x92a)[0x7f01d87904da]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6Parser17ParseTopLevelDeclERNS_9OpaquePtrINS_12DeclGroupRefEEEb+0x3ad)[0x7f01d878eb1d]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6Parser22ParseFirstTopLevelDeclERNS_9OpaquePtrINS_12DeclGroupRefEEE+0x27)[0x7f01d878e687]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang8ParseASTERNS_4SemaEbb+0x1e6)[0x7f01d86d17d6]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang14FrontendAction7ExecuteEv+0x67)[0x7f01da1e1b57]
/usr/bin/clangd[0x70c05d]
/usr/bin/clangd[0x78d6e7]
/usr/bin/clangd[0x788ed9]
/usr/bin/clangd[0x788ab1]
/usr/bin/clangd[0x926e0a]
/lib/x86_64-linux-gnu/libc.so.6(+0x94b43)[0x7f01d0bf9b43]
/lib/x86_64-linux-gnu/libc.so.6(+0x126a00)[0x7f01d0c8ba00]
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):
Signalled during AST worker action: Build AST
Filename: broken.c
Directory: /home/swkfk/data-struct/final
Command Line: /usr/lib/llvm-14/bin/clang -resource-dir=/usr/lib/llvm-14/lib/clang/14.0.0 -- /home/swkfk/data-struct/final/broken.c
Version: 1
[Error - 5:56:33 PM] The Clang Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
[Error - 5:56:33 PM] Request textDocument/codeAction failed.
[object Object]

System information

The version of the clangd extension for VSCode is 0.1.24.
The version of VSCode is 1.79.2

clangd --version
Ubuntu clangd version 14.0.0-1ubuntu1
Features: linux+grpc
Platform: x86_64-pc-linux-gnu

cat /proc/version
Linux version 5.10.16.3-microsoft-standard-WSL2 (oe-user@oe-host) (x86_64-msft-linux-gcc (GCC) 9.3.0, GNU ld (GNU Binutils) 2.34.0.20200220) #1 SMP Fri Apr 2 22:23:49 UTC 2021

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy

@HighCommander4
Copy link

I can reproduce the crash with clangd 14 and clangd 15, but it seems to be fixed in clangd 16.

@zyn0217
Copy link

zyn0217 commented Jun 19, 2023

Perhaps llvm/llvm-project#57517

@HighCommander4
Copy link

Perhaps llvm/llvm-project#57517

Yep, that seems likely based on the issue description and timing of the fix. Nice find!

I will close this a a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants