Fix segmentation fault caused by certain files
AbandonedPublic

Authored by zhigalin on Jul 21 2017, 10:38 AM.

Details

Reviewers
kfunk
Summary

Fix segfault from https://bugs.kde.org/show_bug.cgi?id=381123
This aborts parsing if the top context doesn't exist.
Still need to figure out how it ends there...

Diff Detail

Repository
R52 KDevelop: PHP Support
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
zhigalin created this revision.Jul 21 2017, 10:38 AM
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptJul 21 2017, 10:38 AM
apol added a subscriber: apol.Jul 21 2017, 1:46 PM

Maybe you could add a unit test?

duchain/builders/typebuilder.cpp
517

if (classDec->internalContext())
Note the space and that it's not really necessary to compare to nullptr.

zhigalin marked an inline comment as done.Jul 21 2017, 2:07 PM
In D6807#127164, @apol wrote:

Maybe you could add a unit test?

What I should test?

kfunk added a subscriber: kfunk.Jul 21 2017, 6:30 PM
In D6807#127164, @apol wrote:

Maybe you could add a unit test?

What I should test?

  1. revert your patch
  2. add a test case parsing your test case from https://bugs.kde.org/show_bug.cgi?id=381123#c2 -- make sure running the test case inhibits a crash
  3. reduce the test case as much as possible

3.1) bonus points for actually figuring out why internalContext is nullptr

  1. reapply your patch, make sure running the test no longer crashes
kfunk requested changes to this revision.Jul 21 2017, 6:33 PM
kfunk added inline comments.
duchain/builders/typebuilder.cpp
517
if (auto internalContext = classDec->internalContext()) {
     foreach (Declaration *d, internalContext->findDeclarations(currentQId)) {
This revision now requires changes to proceed.Jul 21 2017, 6:33 PM
zhigalin abandoned this revision.Jul 26 2017, 4:38 PM