Review Request 128762: qmljs: restructure duchain locking to prevent deadlocks
Milian Wolff
mail at milianw.de
Sat Sep 3 21:07:33 UTC 2016
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/128762/#review98848
-----------------------------------------------------------
many good stuff, but also some breakage. and the fact that kevin found an assertion makes me wonder: did you run with this patch in a build with assertions enabled?
languages/qmljs/codecompletion/tests/test_qmljscompletion.cpp (line 125)
<https://git.reviewboard.kde.org/r/128762/#comment66531>
did you make sure that the code in here does the locking itself?
languages/qmljs/duchain/declarationbuilder.cpp (line 126)
<https://git.reviewboard.kde.org/r/128762/#comment66524>
use ENSURE_CHAIN_NOT_LOCKED
languages/qmljs/duchain/declarationbuilder.cpp (line 179)
<https://git.reviewboard.kde.org/r/128762/#comment66525>
maybe it would be a better idea to only unlock+relock in here?
languages/qmljs/duchain/declarationbuilder.cpp (line 201)
<https://git.reviewboard.kde.org/r/128762/#comment66532>
further down in this patch you relock before closing the context. also above you do the same. so why is this not required here?
languages/qmljs/duchain/declarationbuilder.cpp (line 343)
<https://git.reviewboard.kde.org/r/128762/#comment66533>
it's not safe to access the contents of argumentDecls without holding the lock.
languages/qmljs/duchain/declarationbuilder.cpp (line 361)
<https://git.reviewboard.kde.org/r/128762/#comment66534>
this is now unsafe
languages/qmljs/duchain/declarationbuilder.cpp (line 367)
<https://git.reviewboard.kde.org/r/128762/#comment66535>
also, repeatedly locking and unlocking the duchain for write in such a loop is probably a bad idea performance wise. simply locking it once and then doing the write operations in ~1ms or what it takes is going to be much better
languages/qmljs/duchain/declarationbuilder.cpp (line 433)
<https://git.reviewboard.kde.org/r/128762/#comment66536>
unsafe now
languages/qmljs/duchain/declarationbuilder.cpp (line 519)
<https://git.reviewboard.kde.org/r/128762/#comment66537>
is that function locking internally?
languages/qmljs/duchain/declarationbuilder.cpp (line 606)
<https://git.reviewboard.kde.org/r/128762/#comment66526>
undo this change
languages/qmljs/duchain/declarationbuilder.cpp (line 623)
<https://git.reviewboard.kde.org/r/128762/#comment66527>
simply move this out of the block
languages/qmljs/duchain/declarationbuilder.cpp (line 1475)
<https://git.reviewboard.kde.org/r/128762/#comment66530>
this looks wrong. you are accessing the current context and the baseClassesSize etc. in the loop, so the duchain must be locked
languages/qmljs/duchain/expressionvisitor.cpp (line 41)
<https://git.reviewboard.kde.org/r/128762/#comment66528>
use ENSURE_CHAIN_NOT_LOCKED
languages/qmljs/duchain/expressionvisitor.cpp (line 300)
<https://git.reviewboard.kde.org/r/128762/#comment66529>
just to make sure: this function is safely accessing the context and handling the locking for the context internally?
languages/qmljs/duchain/frameworks/nodejs.cpp (line 92)
<https://git.reviewboard.kde.org/r/128762/#comment66542>
dito
languages/qmljs/duchain/frameworks/nodejs.cpp (line 130)
<https://git.reviewboard.kde.org/r/128762/#comment66543>
dito
languages/qmljs/duchain/helper.cpp (line 161)
<https://git.reviewboard.kde.org/r/128762/#comment66538>
dito
languages/qmljs/duchain/helper.cpp (line 282)
<https://git.reviewboard.kde.org/r/128762/#comment66539>
dito
languages/qmljs/duchain/parsesession.cpp (line 236)
<https://git.reviewboard.kde.org/r/128762/#comment66540>
dito
languages/qmljs/duchain/parsesession.cpp (line 269)
<https://git.reviewboard.kde.org/r/128762/#comment66541>
dito
- Milian Wolff
On Sept. 1, 2016, 8:22 p.m., Sven Brauch wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/128762/
> -----------------------------------------------------------
>
> (Updated Sept. 1, 2016, 8:22 p.m.)
>
>
> Review request for KDevelop and Kevin Funk.
>
>
> Bugs: 367825
> http://bugs.kde.org/show_bug.cgi?id=367825
>
>
> Repository: kdevelop
>
>
> Description
> -------
>
> We _must not_ hold a duchain lock when contextOfFile() is called. That
> might try to add something to the background parser queue, which locks
> the background parser mutex; then both locks are held, which causes
> deadlocks.
>
>
> Diffs
> -----
>
> languages/qmljs/codecompletion/context.cpp 3a44f45
> languages/qmljs/codecompletion/tests/test_qmljscompletion.cpp b689418
> languages/qmljs/duchain/declarationbuilder.cpp fb0cb5d
> languages/qmljs/duchain/expressionvisitor.cpp 3b641f5
> languages/qmljs/duchain/frameworks/nodejs.cpp 41964e4
> languages/qmljs/duchain/helper.cpp e537103
> languages/qmljs/duchain/parsesession.cpp d1ad4a9
>
> Diff: https://git.reviewboard.kde.org/r/128762/diff/
>
>
> Testing
> -------
>
> Opened some test project, no crashes, no freezes, and the (I think) reason for the freeze is gone.
>
>
> Thanks,
>
> Sven Brauch
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20160903/a92db169/attachment-0001.html>
More information about the KDevelop-devel
mailing list