Andersbakken / rtags

A client/server indexer for c/c++/objc[++] with integration for Emacs based on clang.
http://www.rtags.net
GNU General Public License v3.0
1.83k stars 252 forks source link

rdm segfault #336

Closed chep closed 9 years ago

chep commented 9 years ago

Hi Anders,

My rdm crashes very often. I think this is because of C++ template but I'm not sure. All I know is that it crashes everytime I write a single line in my tpp file, containing template implementations.

I compiled with debug symbol to get backtrace and I got 2 different ones:

/home/chep/bin/rc --current-file=/home/chep/my-file.tpp --unsaved-file=/home/chep/my-file.tpp:3724 -Y -l /home/chep/my-file.tpp:53:2: Got completion request for /home/chep/my-file.tpp:53:2 [New Thread 0x7ffff1d2c700 (LWP 16679)] [New Thread 0x7ffff252d700 (LWP 16678)] [New Thread 0x7ffff2d2e700 (LWP 16644)]

Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7ffff1d2c700 (LWP 16679)] 0x00007ffff700b916 in ?? () from /usr/lib/libclang.so (gdb) bt

0 0x00007ffff700b916 in ?? () from /usr/lib/libclang.so

1 0x00007ffff70165c1 in ?? () from /usr/lib/libclang.so

2 0x00007ffff40ca927 in llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) ()

from /usr/lib/libLLVM-3.6.so

3 0x00007ffff40ca974 in ?? () from /usr/lib/libLLVM-3.6.so

4 0x00007ffff40f76ed in ?? () from /usr/lib/libLLVM-3.6.so

5 0x00007ffff671c374 in start_thread () from /usr/lib/libpthread.so.0

6 0x00007ffff54a127d in clone () from /usr/lib/libc.so.6

And

(gdb) bt

0 0x0000000000482366 in _M_find_before_node (code=, k=, __n=0,

this=0x75b478) at /usr/include/c++/4.9.2/bits/hashtable.h:1448

1 _M_find_node (c=, key=, __bkt=0, this=0x75b478)

at /usr/include/c++/4.9.2/bits/hashtable.h:625

2 find (__k=, this=0x75b478) at /usr/include/c++/4.9.2/bits/hashtable.h:1321

3 find (__x=, this=0x75b478) at /usr/include/c++/4.9.2/bits/unordered_map.h:578

4 value (ok=0x0, defaultValue=..., key=, this=0x75b478)

at /home/chep/rtags/src/rct/rct/Hash.h:43

5 JobScheduler::dump (this=0x75b3a0, conn=std::shared_ptr (count 9, weak 2) 0x138ff70)

at /home/chep/rtags/src/JobScheduler.cpp:263

6 0x00000000004bb00c in Server::dumpJobs (this=,

conn=std::shared_ptr (count 9, weak 2) 0x138ff70) at /home/chep/rtags/src/Server.cpp:1635

7 0x00000000004d853a in StatusJob::execute (this=)

at /home/chep/rtags/src/StatusJob.cpp:220

8 0x00000000004afba7 in QueryJob::run (this=this@entry=0x7fffffffc8d0,

connection=std::shared_ptr (count 9, weak 2) 0x138ff70) at /home/chep/rtags/src/QueryJob.cpp:228

9 0x00000000004bc2ad in Server::status (this=this@entry=0x75a7e0,

query=std::shared_ptr (count 4, weak 0) 0x138a810,
conn=std::shared_ptr (count 9, weak 2) 0x138ff70) at /home/chep/rtags/src/Server.cpp:1021

10 0x00000000004cd8a6 in Server::handleQueryMessage (this=0x75a7e0,

message=std::shared_ptr (count 4, weak 0) 0x138a810,
conn=std::shared_ptr (count 9, weak 2) 0x138ff70) at /home/chep/rtags/src/Server.cpp:668

11 0x00000000004d0d1e in Server::onNewMessage (this=0x75a7e0,

message=std::shared_ptr (count 81, weak -1) 0xfa4f70,
connection=std::shared_ptr (count 9, weak 2) 0x138ff70) at /home/chep/rtags/src/Server.cpp:331

12 0x00000000004f97d4 in operator() (args#1=..., args#0=..., this=)

---Type to continue, or q to quit--- at /usr/include/c++/4.9.2/functional:2439

13 operator()std::shared_ptr<Message&, std::shared_ptr&> (this=0x138ffb8)

at /home/chep/rtags/src/rct/rct/SignalSlot.h:69

14 Connection::onDataAvailable(std::shared_ptr const&, Buffer&&) (this=,

buf=<optimized out>) at /home/chep/rtags/src/rct/rct/Connection.cpp:183

15 0x000000000051a465 in operator() (

__args#1=<unknown type in /home/chep/bin/rdm, CU 0x1568e48, DIE 0x15a63a6>,
__args#0=std::shared_ptr (count 2, weak 1) 0x138fcd0, this=0x138d158)
at /usr/include/c++/4.9.2/functional:2439

16 operator()std::shared_ptr<SocketClient&, Buffer> (this=0x138fd08)

at /home/chep/rtags/src/rct/rct/SignalSlot.h:69

17 SocketClient::socketCallback (this=0x138fcd0, f=, mode=1)

at /home/chep/rtags/src/rct/rct/SocketClient.cpp:617

18 0x00000000004fdaa9 in operator() (args#1=1, args#0=24, this=0x7fffffffd5c0)

at /usr/include/c++/4.9.2/functional:2439

19 EventLoop::fireSocket (this=this@entry=0x75a3e0, fd=24, mode=1)

at /home/chep/rtags/src/rct/rct/EventLoop.cpp:659

20 0x00000000004feb3d in EventLoop::processSocketEvents (this=this@entry=0x75a3e0,

events=events@entry=0x7fffffffd7d0, eventCount=<optimized out>)
at /home/chep/rtags/src/rct/rct/EventLoop.cpp:798

21 0x000000000050039c in EventLoop::exec (this=0x75a3e0, timeoutTime=timeoutTime@entry=-1)

at /home/chep/rtags/src/rct/rct/EventLoop.cpp:903

22 0x0000000000438a9b in main (argc=, argv=)

at /home/chep/rtags/src/rdm.cpp:677
chep commented 9 years ago

I can reproduce it easily. Each time I use rtags in test.tpp I have a segfault.

Makefile: all: gcc -o test test.cpp

test.cpp:

include "test.hpp"

int main() { int i = 0; Test t(i); t.plus2(); t.plus2(); return t.templateMember; }

test.hpp:

ifndef _TESTHPP

define _TESTHPP

template struct Test { Test(plop p); void plus2(); plop templateMember; };

include "test.tpp"

endif

test.tpp:

template Test::Test(plop p): templateMember(p) { }

template void Test::plus2() { templateMember += 2; }

Andersbakken commented 9 years ago

Sorry about the delay. I can reproduce it. Seems to be an issue with my assumptions in the completion machinery.I'll try to fix it. Thanks for the report.

Andersbakken commented 9 years ago

I think it should work now. Let me know if not.

Anders

chep commented 9 years ago

No more segfault here, thank you very much.

Andersbakken commented 9 years ago

Glad to hear.

Anders

On Mon, Apr 20, 2015 at 11:28 PM, Cédric Chépied notifications@github.com wrote:

No more segfault here, thank you very much.

— Reply to this email directly or view it on GitHub https://github.com/Andersbakken/rtags/issues/336#issuecomment-94653137.