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

crash when using gcc-rtags-wrapper.sh (or rc --compile) #866

Closed brucestephens closed 7 years ago

brucestephens commented 7 years ago

rc --compile /usr/bin/g++ -c hello.cpp provokes a crash (valgrind output seems most readable):


==7260== Command: rdm -j 1
==7260== Parent PID: 2569
==7260==
==7260== Invalid read of size 16
==7260==    at 0x180668: Source::Source(Source const&) (Source.h:28)
==7260==    by 0x1B157B: construct<Source, const Source&> (new_allocator.h:120)
==7260==    by 0x1B157B: construct<Source, const Source&> (alloc_traits.h:455)
==7260==    by 0x1B157B: void std::vector<Source, std::allocator<Source> >::_M_emplace_back_aux<Source const&>(Source const&) (vector.tcc:416)
==7260==    by 0x2EB66B: push_back (stl_vector.h:924)
==7260==    by 0x2EB66B: append (List.h:54)
==7260==    by 0x2EB66B: IndexerJob::IndexerJob(List<Source> const&, Flags<IndexerJob::Flag>, std::shared_ptr<Project> const&, Hash<Path, String> const&) (IndexerJob.cpp:33)
==7260==    by 0x2BB046: Project::reindex(unsigned int, Flags<IndexerJob::Flag>) (Project.cpp:2416)
==7260==    by 0x2BBF84: Project::processParseData(IndexParseData&&) (Project.cpp:2493)
==7260==    by 0x191E57: Server::handleIndexMessage(std::shared_ptr<IndexMessage> const&, std::shared_ptr<Connection> const&) (Server.cpp:604)
==7260==    by 0x19B265: Server::onNewMessage(std::shared_ptr<Message> const&, std::shared_ptr<Connection> const&) (Server.cpp:343)
==7260==    by 0x1F7E36: operator() (functional:2136)
==7260==    by 0x1F7E36: operator()<std::shared_ptr<Message>&, std::shared_ptr<Connection>&> (SignalSlot.h:70)
==7260==    by 0x1F7E36: Connection::onDataAvailable(std::shared_ptr<SocketClient> const&, Buffer&&) (Connection.cpp:151)
==7260==    by 0x222C8A: operator() (functional:2136)
==7260==    by 0x222C8A: operator()<std::shared_ptr<SocketClient>&, Buffer> (SignalSlot.h:70)
==7260==    by 0x222C8A: SocketClient::socketCallback(int, int) (SocketClient.cpp:644)
==7260==    by 0x1FFFC3: operator() (functional:2136)
==7260==    by 0x1FFFC3: EventLoop::fireSocket(int, unsigned int) (EventLoop.cpp:694)
==7260==    by 0x200DF4: EventLoop::processSocketEvents(epoll_event*, int) (EventLoop.cpp:833)
==7260==    by 0x202860: EventLoop::exec(int) (EventLoop.cpp:946)
==7260==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
jwalt commented 7 years ago

I had a similar crash. Superficial debugging showed that Project::source (called from Project::reindex) returns an empty list, which leads to the crash (Source::Source expects at least one element).

I've checked out an earlier commit (nov-1) which works fine for me, so the offending change must be inbetween.

stanford-scs commented 7 years ago

I experience the same problem. Reverted to commit6574451661eb6f3e4912bcd40c61645c2510f56b(dated Nov. 8) and the problem went away.

jwalt commented 7 years ago

I narrowed the problem down to commit 515d0adaef04955c241275f1fb2e0de455d880dd (it is the first to have the crash)

Andersbakken commented 7 years ago

I can't seem to reproduce this. Can you post exact steps to repro?

I'm trying this:

mkdir -p ~/test/foobar cd ~/test/foobar/ touch hello.cpp git init # to make rtags consider this a project rc --compile /usr/bin/g++ -c hello.cpp

Does this reproduce it for you? It doesn't for me. (admittedly running on mac right now, my linux box is down)

regards

Anders

On Tue, Dec 6, 2016 at 7:35 AM, Bruce Stephens notifications@github.com wrote:

rc --compile /usr/bin/g++ -c hello.cpp provokes a crash (valgrind output seems most readable):

==7260== Command: rdm -j 1 ==7260== Parent PID: 2569 ==7260== ==7260== Invalid read of size 16 ==7260== at 0x180668: Source::Source(Source const&) (Source.h:28) ==7260== by 0x1B157B: construct<Source, const Source&> (new_allocator.h:120) ==7260== by 0x1B157B: construct<Source, const Source&> (alloc_traits.h:455) ==7260== by 0x1B157B: void std::vector<Source, std::allocator >::_M_emplace_back_aux<Source const&>(Source const&) (vector.tcc:416) ==7260== by 0x2EB66B: push_back (stl_vector.h:924) ==7260== by 0x2EB66B: append (List.h:54) ==7260== by 0x2EB66B: IndexerJob::IndexerJob(List const&, Flags, std::shared_ptr const&, Hash<Path, String> const&) (IndexerJob.cpp:33) ==7260== by 0x2BB046: Project::reindex(unsigned int, Flags) (Project.cpp:2416) ==7260== by 0x2BBF84: Project::processParseData(IndexParseData&&) (Project.cpp:2493) ==7260== by 0x191E57: Server::handleIndexMessage(std::shared_ptr const&, std::shared_ptr const&) (Server.cpp:604) ==7260== by 0x19B265: Server::onNewMessage(std::shared_ptr const&, std::shared_ptr const&) (Server.cpp:343) ==7260== by 0x1F7E36: operator() (functional:2136) ==7260== by 0x1F7E36: operator()<std::shared_ptr&, std::shared_ptr&> (SignalSlot.h:70) ==7260== by 0x1F7E36: Connection::onDataAvailable(std::shared_ptr const&, Buffer&&) (Connection.cpp:151) ==7260== by 0x222C8A: operator() (functional:2136) ==7260== by 0x222C8A: operator()<std::shared_ptr&, Buffer> (SignalSlot.h:70) ==7260== by 0x222C8A: SocketClient::socketCallback(int, int) (SocketClient.cpp:644) ==7260== by 0x1FFFC3: operator() (functional:2136) ==7260== by 0x1FFFC3: EventLoop::fireSocket(int, unsigned int) (EventLoop.cpp:694) ==7260== by 0x200DF4: EventLoop::processSocketEvents(epoll_event*, int) (EventLoop.cpp:833) ==7260== by 0x202860: EventLoop::exec(int) (EventLoop.cpp:946) ==7260== Address 0x0 is not stack'd, malloc'd or (recently) free'd

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Andersbakken/rtags/issues/866, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEdStfOBdoAWE7N2pj6gFY3WR15MVX7ks5rFYDfgaJpZM4LFiyU .

brucestephens commented 7 years ago

That doesn't crash. But if I do the same in a non-empty project (creating using a compilation database, for example), it does, both on mac and GNU/Linux. i.e.,

touch hello.cpp rc --compile /usr/bin/g++ -c hello.cpp

sthfrnth commented 7 years ago

This crash was introduced in 515d0ad. When calling IndexerJob::IndexerJob, s.size() == 0. Anders, do you have any quick idea?

Andersbakken commented 7 years ago

Sorry about the delay.

I still can't seem to reproduce this for some reason but I check in something that I think should make it only print and error when it happens and not crash.

regards

Anders

On Tue, Dec 6, 2016 at 7:35 AM, Bruce Stephens notifications@github.com wrote:

rc --compile /usr/bin/g++ -c hello.cpp provokes a crash (valgrind output seems most readable):

==7260== Command: rdm -j 1 ==7260== Parent PID: 2569 ==7260== ==7260== Invalid read of size 16 ==7260== at 0x180668: Source::Source(Source const&) (Source.h:28) ==7260== by 0x1B157B: construct<Source, const Source&> (new_allocator.h:120) ==7260== by 0x1B157B: construct<Source, const Source&> (alloc_traits.h:455) ==7260== by 0x1B157B: void std::vector<Source, std::allocator >::_M_emplace_back_aux<Source const&>(Source const&) (vector.tcc:416) ==7260== by 0x2EB66B: push_back (stl_vector.h:924) ==7260== by 0x2EB66B: append (List.h:54) ==7260== by 0x2EB66B: IndexerJob::IndexerJob(List const&, Flags, std::shared_ptr const&, Hash<Path, String> const&) (IndexerJob.cpp:33) ==7260== by 0x2BB046: Project::reindex(unsigned int, Flags) (Project.cpp:2416) ==7260== by 0x2BBF84: Project::processParseData(IndexParseData&&) (Project.cpp:2493) ==7260== by 0x191E57: Server::handleIndexMessage(std::shared_ptr const&, std::shared_ptr const&) (Server.cpp:604) ==7260== by 0x19B265: Server::onNewMessage(std::shared_ptr const&, std::shared_ptr const&) (Server.cpp:343) ==7260== by 0x1F7E36: operator() (functional:2136) ==7260== by 0x1F7E36: operator()<std::shared_ptr&, std::shared_ptr&> (SignalSlot.h:70) ==7260== by 0x1F7E36: Connection::onDataAvailable(std::shared_ptr const&, Buffer&&) (Connection.cpp:151) ==7260== by 0x222C8A: operator() (functional:2136) ==7260== by 0x222C8A: operator()<std::shared_ptr&, Buffer> (SignalSlot.h:70) ==7260== by 0x222C8A: SocketClient::socketCallback(int, int) (SocketClient.cpp:644) ==7260== by 0x1FFFC3: operator() (functional:2136) ==7260== by 0x1FFFC3: EventLoop::fireSocket(int, unsigned int) (EventLoop.cpp:694) ==7260== by 0x200DF4: EventLoop::processSocketEvents(epoll_event*, int) (EventLoop.cpp:833) ==7260== by 0x202860: EventLoop::exec(int) (EventLoop.cpp:946) ==7260== Address 0x0 is not stack'd, malloc'd or (recently) free'd

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Andersbakken/rtags/issues/866, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEdStfOBdoAWE7N2pj6gFY3WR15MVX7ks5rFYDfgaJpZM4LFiyU .

sthfrnth commented 7 years ago

Thank you Anders. Now there is no crash. But rtags is not indexing any file in my project. It complains "GOT EMPTY LIST OF" for all source files. Indexing for rtags itself's source code is OK. I can not find the reason myself. There is not this problem after reverting back to the parent of 515d0ad.

Andersbakken commented 7 years ago

Ah. I get it now.

Should be fixed now. Thanks for the report.

Anders

On Tue, Dec 13, 2016 at 8:41 PM, sthfrnth notifications@github.com wrote:

Thank you Anders. Now there is no crash. But rtags is not indexing any file in my project. It complains "GOT EMPTY LIST OF" for all source files. Indexing for rtags itself's source code is OK. I can not find the reason myself. There is not this problem after reverting back to the parent of 515d0ad https://github.com/Andersbakken/rtags/commit/515d0adaef04955c241275f1fb2e0de455d880dd .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Andersbakken/rtags/issues/866#issuecomment-266941036, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEdSqQmsl3YH3zMCGE0bc9FEKthf5bgks5rH3NdgaJpZM4LFiyU .

sthfrnth commented 7 years ago

This time it is really fixed. Thank you Anders.

Andersbakken commented 7 years ago

Good to hear.

Anders