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 when parse cpp file #602

Closed
lovelyzzc opened this issue Jan 3, 2024 · 1 comment
Closed

crash when parse cpp file #602

lovelyzzc opened this issue Jan 3, 2024 · 1 comment

Comments

@lovelyzzc
Copy link

lovelyzzc commented Jan 3, 2024

When I convert CPP files in the project, it causes a coredump. Below is the printout:

#0 0x00007ff1d7f6f503 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/libLLVM-16.so+0xe1f503)
#1 0x00007ff1d7f6c7bf llvm::sys::RunSignalHandlers() (/usr/lib/libLLVM-16.so+0xe1c7bf)
#2 0x00007ff1d7f6c90d (/usr/lib/libLLVM-16.so+0xe1c90d)
#3 0x00007ff1d6c1f710 (/usr/lib/libc.so.6+0x3e710)
#4 0x00007ff1dfcb1c6c (/usr/lib/libclang-cpp.so.16+0x780c6c)
#5 0x00007ffe703c08f0 
fish: Job 1, 'insights ../src/app.cpp' terminated by signal SIGSEGV (Address boundary error)

But I can successfully convert HPP files. Below is the printout of insights --version.

cpp-insights 0.10 https://cppinsights.io (https://github.com/andreasfertig/cppinsights.git 9147b894b814a3d7dcf82ac9b16965680baffeb1)
  LLVM  Revision: 
  Clang Revision: Clang 16.0.6

I used the tag v_0.10 for compilation, and the cmake compile command is as follows.

cmake -G"Ninja" .. -DINSIGHTS_USE_SYSTEM_INCLUDES=off -DCLANG_LINK_CLANG_DYLIB=on -DLLVM_LINK_LLVM_DYLIB=on

Below is the printout of ldd.

lovelyzzc@DRW-DZ0569 ~/c/build ((v_0.10))> ldd insights
        linux-vdso.so.1 (0x00007fff49de2000)
        libclang-cpp.so.16 => /usr/lib/libclang-cpp.so.16 (0x00007fd4a367c000)
        libLLVM-16.so => /usr/lib/libLLVM-16.so (0x00007fd49b29b000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fd49b020000)
        libm.so.6 => /usr/lib/libm.so.6 (0x00007fd49af33000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007fd49af0e000)
        libc.so.6 => /usr/lib/libc.so.6 (0x00007fd49ad2c000)
        /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007fd4a6ed4000)
        libffi.so.8 => /usr/lib/libffi.so.8 (0x00007fd49ad1f000)
        libedit.so.0 => /usr/lib/libedit.so.0 (0x00007fd49ace3000)
        libz.so.1 => /usr/lib/libz.so.1 (0x00007fd49acc9000)
        libzstd.so.1 => /usr/lib/libzstd.so.1 (0x00007fd49abf6000)
        libncursesw.so.6 => /usr/lib/libncursesw.so.6 (0x00007fd49ab7f000)
        libxml2.so.2 => /usr/lib/libxml2.so.2 (0x00007fd49aa15000)
        liblzma.so.5 => /usr/lib/liblzma.so.5 (0x00007fd49a9e0000)
        libicuuc.so.74 => /usr/lib/libicuuc.so.74 (0x00007fd49a7d2000)
        libicudata.so.74 => /usr/lib/libicudata.so.74 (0x00007fd498a74000)

Below is the printout from lldb.

(lldb) target create "insights"
Current executable set to '/usr/local/bin/insights' (x86_64).
(lldb) r ../src/app.cpp -p ../build/ --use-libc++
Process 11488 launched: '/usr/local/bin/insights' (x86_64)
/home/lovelyzzc/vehicle_end/safety/src/app.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
         ^~~~~~~~~~
Process 11488 stopped
* thread #1, name = 'insights', stop reason = signal SIGSEGV: address access protected (fault address: 0x7ffff5298c6c)
    frame #0: 0x00007ffff5298c6c libclang-cpp.so.16`___lldb_unnamed_symbol29515 + 6
libclang-cpp.so.16`___lldb_unnamed_symbol29515:
->  0x7ffff5298c6c <+6>: addb   %al, (%rax)
    0x7ffff5298c6e <+8>: ud2    

libclang-cpp.so.16`___lldb_unnamed_symbol29516:
    0x7ffff5298c70 <+0>: movl   0x8, %eax
    0x7ffff5298c77 <+7>: andl   $-0x9, %eax
(lldb) bt
* thread #1, name = 'insights', stop reason = signal SIGSEGV: address access protected (fault address: 0x7ffff5298c6c)
  * frame #0: 0x00007ffff5298c6c libclang-cpp.so.16`___lldb_unnamed_symbol29515 + 6
    frame #1: 0x00007fffffff8170

Where should I start to troubleshoot this issue?
Thanks!

@andreasfertig
Copy link
Owner

Hello @lovelyzzc,

sorry for the trouble!

In your lldb printout, this line sticks out:

/home/lovelyzzc/vehicle_end/safety/src/app.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
         ^~~~~~~~~~

C++ Insights cannot find the iostream header. This would be the starting point. The option INSIGHTS_USE_SYSTEM_INCLUDES is probably named in a hard-to-guess way. What it means is that all -I includes become -isystem with the option on and otherwise remain untouched. I'm not sure whether this option does what you're expecting.

Andreas

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

2 participants