Bug 373177 - DUChain segfault when importing project to ruby::UseBuilder::visitName
Summary: DUChain segfault when importing project to ruby::UseBuilder::visitName
Status: RESOLVED WORKSFORME
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: Ruby (show other bugs)
Version: git master
Platform: Other Linux
: NOR crash
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-02 09:10 UTC by Leslie Zhai
Modified: 2021-01-16 04:35 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Leslie Zhai 2016-12-02 09:10:48 UTC
Hi kdev-ruby developers,

I read about http://kfunk.org/2016/11/30/kdevelop-seeking-maintainer-for-ruby-language-support/ and try to be familiar with parser and AST ;-)

I added include(ECMEnableSanitizers) to kdev-ruby, kdevplatform and kdevelop's CMakeLists.txt and build with:

cmake .. -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_CXX_COMPILER=clang++    \
    -DECM_ENABLE_SANITIZERS='address;leak;undefined'    \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DBUILD_TESTING=ON

then I tried to import redmine (a bug tracker written in ruby) project, there are some tiny bugs https://git.reviewboard.kde.org/r/129599/
https://git.reviewboard.kde.org/r/129600/

but DUChain segfault issue is difficult to fix!

kdevplatform.language: creating parse-job "/data/project/redmine/db/migrate/20091123212029_add_default_done_ratio_to_issue_status.rb" new count of active parse-jobs: 4
kdevelop.languages.python.duchain: "mixed"
kdevelop.languages.python.duchain: is first: true true 0x606001332b00
/usr/include/kdevplatform/language/duchain/navigation/../duchainpointer.h:145:36: runtime error: member call on null pointer of type 'KDevelop::DUChainPointerData'
SUMMARY: AddressSanitizer: undefined-behavior /usr/include/kdevplatform/language/duchain/navigation/../duchainpointer.h:145:36 in 
/data/project/kde/kdevplatform/language/duchain/duchainpointer.cpp:27:10: runtime error: member access within null pointer of type 'KDevelop::DUChainPointerData'
SUMMARY: AddressSanitizer: undefined-behavior /data/project/kde/kdevplatform/language/duchain/duchainpointer.cpp:27:10 in 
ASAN:DEADLYSIGNAL
=================================================================
==24880==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000008 (pc 0x7f07974b3b2a bp 0x7f06d9a74f90 sp 0x7f06d9a74f70 T12)
==24880==The signal is caused by a READ memory access.
==24880==Hint: address points to the zero page.
    #0 0x7f07974b3b29 in KDevelop::DUChainPointerData::base() /data/project/kde/kdevplatform/language/duchain/duchainpointer.cpp:27:10
kdevelop.languages.ruby.duchain: Compiling
    #1 0x7f06db243e0f in KDevelop::DUChainPointer<KDevelop::DUContext>::operator->() const /usr/include/kdevplatform/language/duchain/navigation/../duchainpointer.h:145:36
    #2 0x7f06db23887b in ruby::getDeclaration(KDevelop::QualifiedIdentifier const&, KDevelop::RangeInRevision const&, KDevelop::DUChainPointer<KDevelop::DUContext> const&, ruby::DeclarationKind) /data/project/kde/kdev-ruby/duchain/helpers.cpp:184:30
    #3 0x7f06db30176d in ruby::UseBuilder::visitName(ruby::Ast*) /data/project/kde/kdev-ruby/duchain/builders/usebuilder.cpp:48:17
    #4 0x7f06db301f4e in non-virtual thunk to ruby::UseBuilder::visitName(ruby::Ast*) /data/project/kde/kdev-ruby/duchain/builders/usebuilder.cpp:44:18
    #5 0x7f06db758285 in ruby::AstVisitor::visitNode(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:679:17
    #6 0x7f06db7675c1 in ruby::AstVisitor::visitBlockVariables(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:511:9
    #7 0x7f06db766fc3 in ruby::AstVisitor::visitBlock(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:497:5
    #8 0x7f06db3290b6 in ruby::ContextBuilder::visitBlock(ruby::Ast*) /data/project/kde/kdev-ruby/duchain/builders/contextbuilder.cpp:238:17
    #9 0x7f06db3069a9 in ruby::UseBuilder::visitMethodCall(ruby::Ast*) /data/project/kde/kdev-ruby/duchain/builders/usebuilder.cpp:124:5
    #10 0x7f06db30afbe in non-virtual thunk to ruby::UseBuilder::visitMethodCall(ruby::Ast*) /data/project/kde/kdev-ruby/duchain/builders/usebuilder.cpp:98:18
    #11 0x7f06db76af61 in ruby::AstVisitor::checkMethodCall(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:794:13
    #12 0x7f06db756cc2 in ruby::AstVisitor::visitNode(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:655:33
    #13 0x7f06db75a9e7 in ruby::AstVisitor::visitStatements(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:728:9
    #14 0x7f06db75fc9f in ruby::AstVisitor::visitAssignmentStatement(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:256:5
    #15 0x7f06db756e3c in ruby::AstVisitor::visitNode(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:657:31
    #16 0x7f06db307d50 in ruby::UseBuilder::visitMethodCallMembers(ruby::Ast*) /data/project/kde/kdev-ruby/duchain/builders/usebuilder.cpp:146:29
    #17 0x7f06db305ca3 in ruby::UseBuilder::visitMethodCall(ruby::Ast*) /data/project/kde/kdev-ruby/duchain/builders/usebuilder.cpp:110:5
    #18 0x7f06db30afbe in non-virtual thunk to ruby::UseBuilder::visitMethodCall(ruby::Ast*) /data/project/kde/kdev-ruby/duchain/builders/usebuilder.cpp:98:18
    #19 0x7f06db76af61 in ruby::AstVisitor::checkMethodCall(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:794:13
    #20 0x7f06db756cc2 in ruby::AstVisitor::visitNode(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:655:33
    #21 0x7f06db7600d5 in ruby::AstVisitor::visitIfStatement(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:270:5
    #22 0x7f06db755d01 in ruby::AstVisitor::visitNode(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:642:11
    #23 0x7f06db75a9e7 in ruby::AstVisitor::visitStatements(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:728:9
    #24 0x7f06db75fc9f in ruby::AstVisitor::visitAssignmentStatement(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:256:5
    #25 0x7f06db756e3c in ruby::AstVisitor::visitNode(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:657:31
    #26 0x7f06db75a9e7 in ruby::AstVisitor::visitStatements(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:728:9
    #27 0x7f06db75b0a3 in ruby::AstVisitor::visitBody(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:96:5
    #28 0x7f06db327a0e in ruby::ContextBuilder::visitMethodStatement(ruby::Ast*) /data/project/kde/kdev-ruby/duchain/builders/contextbuilder.cpp:222:5
    #29 0x7f06db32897e in non-virtual thunk to ruby::ContextBuilder::visitMethodStatement(ruby::Ast*) /data/project/kde/kdev-ruby/duchain/builders/contextbuilder.cpp:199:22
    #30 0x7f06db756a4b in ruby::AstVisitor::visitNode(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:653:30
    #31 0x7f06db75a9e7 in ruby::AstVisitor::visitStatements(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:728:9
    #32 0x7f06db75b0a3 in ruby::AstVisitor::visitBody(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:96:5
    #33 0x7f06db764cf8 in ruby::AstVisitor::visitClassStatement(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:401:5
    #34 0x7f06db3261ef in ruby::ContextBuilder::visitClassStatement(ruby::Ast*) /data/project/kde/kdev-ruby/duchain/builders/contextbuilder.cpp:195:21
    #35 0x7f06db32622e in non-virtual thunk to ruby::ContextBuilder::visitClassStatement(ruby::Ast*) /data/project/kde/kdev-ruby/duchain/builders/contextbuilder.cpp:192:22
    #36 0x7f06db7565dd in ruby::AstVisitor::visitNode(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:650:27
    #37 0x7f06db754d47 in ruby::AstVisitor::visitCode(ruby::Ast*) /data/project/kde/kdev-ruby/parser/astvisitor.cpp:43:9
    #38 0x7f06db325c36 in ruby::ContextBuilder::startVisiting(ruby::Ast*) /data/project/kde/kdev-ruby/duchain/builders/contextbuilder.cpp:182:17
    #39 0x7f06dba6bd46 in KDevelop::AbstractContextBuilder<ruby::Ast, ruby::NameAst>::supportBuild(ruby::Ast*, KDevelop::DUContext*) /usr/include/kdevplatform/language/duchain/builders/abstractcontextbuilder.h:135:5
    #40 0x7f06dba69c04 in KDevelop::AbstractUseBuilder<ruby::Ast, ruby::NameAst, ruby::ContextBuilder>::buildUses(ruby::Ast*) /usr/include/kdevplatform/language/duchain/builders/abstractusebuilder.h:74:37
    #41 0x7f06dba607ff in ruby::ParseJob::run(QSharedPointer<ThreadWeaver::JobInterface>, ThreadWeaver::Thread*) /data/project/kde/kdev-ruby/parsejob.cpp:147:24
    #42 0x7f06dba6675b in non-virtual thunk to ruby::ParseJob::run(QSharedPointer<ThreadWeaver::JobInterface>, ThreadWeaver::Thread*) /data/project/kde/kdev-ruby/parsejob.cpp:62:16
    #43 0x7f07958ac585 in ThreadWeaver::IdDecorator::run(QSharedPointer<ThreadWeaver::JobInterface>, ThreadWeaver::Thread*) (/usr/lib/libKF5ThreadWeaver.so.5+0x18585)
    #44 0x7f07958acb87 in ThreadWeaver::Executor::run(QSharedPointer<ThreadWeaver::JobInterface> const&, ThreadWeaver::Thread*) (/usr/lib/libKF5ThreadWeaver.so.5+0x18b87)
    #45 0x7f07958aba99 in ThreadWeaver::Job::execute(QSharedPointer<ThreadWeaver::JobInterface> const&, ThreadWeaver::Thread*) (/usr/lib/libKF5ThreadWeaver.so.5+0x17a99)
    #46 0x7f07958ab13f in ThreadWeaver::Thread::run() (/usr/lib/libKF5ThreadWeaver.so.5+0x1713f)
    #47 0x7f079c540d77  (/usr/lib/libQt5Core.so.5+0xacd77)
    #48 0x7f079bbf2453 in start_thread (/usr/lib/libpthread.so.0+0x7453)
    #49 0x7f079b3127de in __GI___clone (/usr/lib/libc.so.6+0xe87de)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /data/project/kde/kdevplatform/language/duchain/duchainpointer.cpp:27:10 in KDevelop::DUChainPointerData::base()
Thread T12 (Queue(0x6040002) created by T11 (Queue(0x6040002) here:
    #0 0x436c4d in pthread_create (/data/project/kde/kdevelop/build/app/kdevelop+0x436c4d)
    #1 0x7f079c540278 in QThread::start(QThread::Priority) (/usr/lib/libQt5Core.so.5+0xac278)

Thread T11 (Queue(0x6040002) created by T0 here:
    #0 0x436c4d in pthread_create (/data/project/kde/kdevelop/build/app/kdevelop+0x436c4d)
    #1 0x7f079c540278 in QThread::start(QThread::Priority) (/usr/lib/libQt5Core.so.5+0xac278)

==24880==ABORTING

and there are a lot of runtime errors detected by UBSan:

SUMMARY: AddressSanitizer: undefined-behavior /data/project/kde/kdevplatform/language/duchain/importers.cpp:98:40 in 
/data/project/kde/kdevplatform/language/duchain/importers.cpp:98:40: runtime error: reference binding to misaligned address 0x6310000f083e for type 'const KDevelop::DeclarationId', which requires 4 byte alignment
0x6310000f083e: note: pointer points here
 00 00 00 00 3e 0f  01 00 00 00 00 00 00 00  00 00 00 00 00 00 02 00  00 00 7f 00 00 00 05 00  00 00
             ^ 
SUMMARY: AddressSanitizer: undefined-behavior /data/project/kde/kdevplatform/language/duchain/importers.cpp:98:40 in 
/data/project/kde/kdevplatform/language/duchain/importers.cpp:136:42: runtime error: member call on misaligned address 0x6310000f083e for type 'KDevelop::ImportersItem', which requires 4 byte alignment
0x6310000f083e: note: pointer points here
 00 00 00 00 3e 0f  01 00 00 00 00 00 00 00  00 00 00 00 00 00 02 00  00 00 7f 00 00 00 05 00  00 00
             ^ 
SUMMARY: AddressSanitizer: undefined-behavior /data/project/kde/kdevplatform/language/duchain/importers.cpp:136:42 in 
/data/project/kde/kdevplatform/language/duchain/importers.cpp:137:19: runtime error: member call on misaligned address 0x6310000f083e for type 'KDevelop::ImportersItem', which requires 4 byte alignment
0x6310000f083e: note: pointer points here
 00 00 00 00 3e 0f  01 00 00 00 00 00 00 00  00 00 00 00 00 00 02 00  00 00 7f 00 00 00 05 00  00 00
             ^ 
.
.
.

Regards,
Leslie Zhai
Comment 1 Kevin Funk 2016-12-02 09:46:40 UTC
FWIW: You should ignore the misalignment warnings from UBSan, the DUChain does regular misaligned access to pointers. Known issue.

Pass -fno-sanitize=alignment when compiling the code.
Comment 2 Justin Zobel 2020-12-17 05:23:56 UTC
Thank you for the crash report.

As it has been a while since this was reported, can you please test and confirm if this issue is still occurring or if this bug report can be marked as resolved.

I have set the bug status to "needsinfo" pending your response, please change back to "reported" or "resolved/worksforme" when you respond, thank you.
Comment 3 Bug Janitor Service 2021-01-01 04:36:06 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 4 Bug Janitor Service 2021-01-16 04:35:11 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!