-
Notifications
You must be signed in to change notification settings - Fork 99
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 in libclang: ASTTypeWriter::VisitTagType() and CompilerInstance::~CompilerInstance() #191
Comments
Hi Sarcasm, Thanks for the helpful response. Sorry for originally posting in the wrong thread.
OS X 10.10.3
Running the irony-server with compile options results in this error:
I'll have to do some testing. Can I test with the server binary and line 1 column 1 on a bunch of source files (with their flags), or do I actually need to find a reasonable line and column in the file? I could also build a quick test project to test on something simple. Thanks, |
Okay, I think some flags may be responsible for this:
You can use |
I tried autocomplete on a simpler file that uses all the same compiler flags (including -MMD, -MP, -DBUILD_VERSION=string, -DEBUILD_TIME=stringWithSpaces) and everything seems to work. Irony-server parse works great on this file (at least it takes a second or two then reports "t \n\n ;;EOT". irony-server complete looked like it was working as well, returning reasonable suggestions. In Emacs I can put my cursor after the dereference of a custom class pointer inside the simpler file, run M-x irony-completion-at-point-async RET and get "Complete, but not unique". When I run M-x company-complete, I get the dropdown list of all the public member variables and member functions, just like I'd expect! The only weird thing is that after I get the successful autocomplete, if I run M-x irony-cdb-menu, it responds "No compilation database in use. [q] to quit" I suppose that narrows down the problem to libclang parsing the first file. That seems strange since it builds and runs fine. The next step to identifying the root cause is to probably start commenting out portions of the problem file. Thanks, |
To be extra-sure that you are using
Before the successful complete it wasn't empty? I would be surprised if the compile option changes for no apparent reasons. This is not something that is "smartly" refreshed or anything, the flags are set when
Yep you can try that. I was wondering if you could print the value of the variable: For testing purpose you can also edit this variable directly to remove the suspicious compile options. |
Yep, if I call M-x company-irony RET on a simple file I get proper autocompletion.
It was empty before and after calling irony async. I guess I'm surprised that I'm getting valid auto completions if the irony-cdb-menu says "No compilation database in use." Apparently this message does not indicate a problem?
|
Okay, as you can see this is a bug in the compile options: You have:
I think it should be:
Type (setq irony--compile-options '("-std=c++1y" "-stdlib=libc++" "-Wall" "-Wno-deprecated-declarations" "-I./src" "-isystem" "/Users/danschoppe/local/include/" "-isystem" "/Users/danschoppe/local/include/libxml2" "-isystem" "./external" "-isystem" "./build/msgpack/include" "-isystem" "/usr/local/include" "-O0" "-fno-inline" "-g" "-Ibuild/debug" "-DBUILD_VERSION=\"v1.0.0\"" "-DBUILD_TIME=\"2015-04-13 23:59:15-0500\"" "-isystem" "./OSX/deps" "-mmacosx-version-min=10.8" "-isysroot" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk") If it doesn't work, and if you know if you can compile without -DBUILD_VERSION and -DBUILD_TIME, you can try to remove these one as well, maybe I failed the string escaping.
Without compile options libclang is able to figure some things out but since it cannot find header files it will not complete structures from header files, it will not be able to compute a preamble so things may be sluggish, ...It still manage to do some things but that's not the best. "No compilation database in use" may be a valid message in a new buffer for example, the message isn't necessarily a sign of error but in your case it is not right. |
I tried removing the -DBUILD_VERSION and -DBUILD_TIME from my project but was running into the same issue. I also did some irony-server parse testing with and without the -DBUILD_* flags but the behavior did not change. Some files parse fine, others hit this libclang crash. It seems like using irony-server parse is the most controlled environment I have to track down the issue. Is there a way to use irony-server with a different version of llvm, or do I need to recompile the server? I'm curious to try it with 3.6 instead of 3.5.1. |
You have to recompile but it shouldn't be too difficult since you already know about |
Sarcasm, I brew installed llvm 3.6.0 and recompiled irony-server. I needed to set some additional flags in order for the installation to find the include dir and lib (I suspect because llvm36 uses command "llvm-config-3.6" instead of "llvm-config"):
I used the new irony-server to try parsing some files that previously failed to parse. It worked, even with the -DBUILD_VERSION and -DBUILD_TIME flags! But to reduce variables, I did recompile my application without the -DBUILD_VERSION and -DBUILD_TIME flags. So I hopped back to Emacs and tried M-x company-irony in a few spots. In some files it was working great, and in other files It was still reporting "Cannot complete at point". M-x irony-completion-at-point-async in the problematic files still reports "Wrong type argument: sequencep, libclang:" If I run irony-server -d complete [file] [line] [column] on a problem file, some errors are output before it hits a seg fault:
Some thoughts:
|
Update: I think it's working! It seems to be working after running your suggested M-: command:
So what do you make of all this? Thanks for the help, |
I'm not sure but I think that you may have to use a different prefix path. Either:
Or:
If you have To verify on Linux, you would do:
In some case it may be necessary to tell CMake to set the RPATH so the proper lib is found, and not the system wide one (see Bottom of FAQ: https://github.com/Sarcasm/irony-mode#faq). Can you make sure the built-in headers are found when you build with llvm 3.6: You should have something like this:
I don't know, don't understand everything. Can you use the CDB without manual modification, and print the content of Then I guess, one would have to try each of the differences to find out which one affects the result. |
@DanSchoppe: I'm creating a dedicated issue for: #137 (comment)
So you are using LLVM 3.5.1, what about your OS?
Since it's not using the CMake generator, I would be interested in seeing the flag in use. For example, it seems that
-Qunused-arguments
doesn't play nice with libclang, see Sarcasm/company-irony#8Printing the output of
M-x irony-cdb-menu RET
would be helpful.You got a libclang crash, that's how it is printed for now, this is a known issue, ideally I should intercept this, see #157.
I believe that's is expected, irony--compile-options is a buffer-local variable, that contains the compile options in use for the current buffer, it is not the full JSON compilation database (this one doesn't stay in memory).
Testing in a bash terminal is very helpful:
It would be nice if you could:
./irony-server -d complete [path/to/source/file.cpp] 100 7
RET-std=c++11 -I<path/to/include> <other compile options...>
RETThe crash seems to be in libclang but maybe irony isn't using the API properly somewhere.
The text was updated successfully, but these errors were encountered: