This repository has been archived by the owner on Jul 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 162
Indexing .. failed with errno=1
because in libclang/CXIndexDataConsumer.cpp
, handleReferences
may be passed nullptr DeclContext to
#192
Comments
been having the same issue with nlohmann/json for some time. This diff in libclang "fixes" it, but i have no idea why DC is null in the first place, and i don't have the time to rebuild llvm with debug symbols on my laptop: Index: CXIndexDataConsumer.cpp
===================================================================
--- CXIndexDataConsumer.cpp (revision 321065)
+++ CXIndexDataConsumer.cpp (working copy)
@@ -892,6 +892,8 @@
CXIdxEntityRefKind Kind) {
if (!D)
return false;
+ if (!DC)
+ return false;
CXCursor Cursor = E ? MakeCXCursor(E, cast<Decl>(DC), CXTU)
: getRefCursor(D, Loc);
@@ -909,6 +911,8 @@
if (!D)
return false;
+ if (!DC)
+ return false;
if (Loc.isInvalid())
return false;
if (!shouldIndexFunctionLocalSymbols() && isFunctionLocalDecl(D)) |
On Linux, if you have installed radare2 and use r2 -nwqc 'wx 4d85c0 @ 0x47aece' build/release/lib/clang+llvm-5.0.1-x86_64-linux-gnu-ubuntu-14.04/lib/libclang.so.5.0 |
According to System V x86-64 ABI, its parameters are passed in the following way:
We know
Which can be achieved with
or
|
This was referenced Jan 3, 2018
spurious
pushed a commit
to spurious/clang-mirror
that referenced
this issue
Jan 8, 2018
Summary: DC may sometimes be NULL and getContainerInfo(DC, Container) will dereference a null pointer. Default template arguments (the following example and many test files in https://github.com/nlohmann/json) may cause null pointer dereference. ```c++ template <typename> struct actor; template <template <typename> class Actor = actor> struct terminal; ``` In tools/libclang/CXIndexDataConsumer.cpp#L203 handleReference(ND, Loc, Cursor, dyn_cast_or_null<NamedDecl>(ASTNode.Parent), ASTNode.ContainerDC, ASTNode.OrigE, Kind); `dyn_cast_or_null<NamedDecl>(ASTNode.Parent)` is somehow a null pointer and in tools/libclang/CXIndexDataConsumer.cpp:935 ContainerInfo Container; getContainerInfo(DC, Container); The null DC is casted `ContInfo.cursor = getCursor(cast<Decl>(DC));` and SIGSEGV. ``` See discussions in jacobdufault/cquery#219 jacobdufault/cquery#192 Reviewers: akyrtzi, sammccall, yvvan Reviewed By: sammccall Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D41575 git-svn-id: http://llvm.org/svn/llvm-project/cfe/trunk@322017 91177308-0d34-0410-b5e6-96231b3b80d8
jyknight
pushed a commit
to jyknight/llvm-monorepo
that referenced
this issue
Jan 8, 2018
Summary: DC may sometimes be NULL and getContainerInfo(DC, Container) will dereference a null pointer. Default template arguments (the following example and many test files in https://github.com/nlohmann/json) may cause null pointer dereference. ```c++ template <typename> struct actor; template <template <typename> class Actor = actor> struct terminal; ``` In tools/libclang/CXIndexDataConsumer.cpp#L203 handleReference(ND, Loc, Cursor, dyn_cast_or_null<NamedDecl>(ASTNode.Parent), ASTNode.ContainerDC, ASTNode.OrigE, Kind); `dyn_cast_or_null<NamedDecl>(ASTNode.Parent)` is somehow a null pointer and in tools/libclang/CXIndexDataConsumer.cpp:935 ContainerInfo Container; getContainerInfo(DC, Container); The null DC is casted `ContInfo.cursor = getCursor(cast<Decl>(DC));` and SIGSEGV. ``` See discussions in jacobdufault/cquery#219 jacobdufault/cquery#192 Reviewers: akyrtzi, sammccall, yvvan Reviewed By: sammccall Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D41575 llvm-svn=322017
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
This is an issue of libclang 4.0.0 up to recently released 5.0.1
If you use
cquery --log-file /tmp/cq.log "$@"
, you'll seeerrno=1
indicatesCXError_Failure
which is caught by clang'sCrashRecoveryContext
(you can addclang_toggleCrashRecovery(0)
just before theclang_indexTranslationUnit
call to let it crash and see the stack trace in a debugger).This SIGSEGV is caused by:
https://github.com/llvm-mirror/clang/blob/master/tools/libclang/CXIndexDataConsumer.cpp#L203
handleReference(ND, Loc, Cursor, dyn_cast_or_null<NamedDecl>(ASTNode.Parent), ASTNode.ContainerDC, ASTNode.OrigE, Kind);
dyn_cast_or_null<NamedDecl>(ASTNode.Parent)
is somehow a null pointer and in https://github.com/llvm-mirror/clang/blob/master/tools/libclang/CXIndexDataConsumer.cpp#L935The null
DC
is castedContInfo.cursor = getCursor(cast<Decl>(DC));
and SIGSEGV.The text was updated successfully, but these errors were encountered: