Bug 263532 - Kdevelop crashes while parsing project
Summary: Kdevelop crashes while parsing project
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: PHP (show other bugs)
Version: git master
Platform: Gentoo Packages Linux
: VHI crash
Target Milestone: 4.2.0
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-18 11:48 UTC by Florian 'branleb' Zumkeller-Quast
Modified: 2011-01-18 20:13 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
crash file from crash assistang (35.25 KB, text/plain)
2011-01-18 11:48 UTC, Florian 'branleb' Zumkeller-Quast
Details
The ebuilds i used to compile kdev from git sources (2.33 KB, application/x-gzip)
2011-01-18 11:48 UTC, Florian 'branleb' Zumkeller-Quast
Details
the last parsed file according to the stdout (1.98 KB, text/html)
2011-01-18 11:49 UTC, Florian 'branleb' Zumkeller-Quast
Details
the last lines of the stdout describing the crash (4.19 KB, text/plain)
2011-01-18 11:52 UTC, Florian 'branleb' Zumkeller-Quast
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Florian 'branleb' Zumkeller-Quast 2011-01-18 11:48:18 UTC
Created attachment 56159 [details]
crash file from crash assistang

Version:           SVN (using KDE 4.5.5) 
OS:                Linux

I have a big project using PHP loaded into Kdevelop.



Reproducible: Always

Steps to Reproduce:
Start kdevelop.
It loads the last active project and crashes after some time

Actual Results:  
it crashes

Expected Results:  
it should run and parse the project sources
Comment 1 Florian 'branleb' Zumkeller-Quast 2011-01-18 11:48:57 UTC
Created attachment 56160 [details]
The ebuilds i used to compile kdev from git sources
Comment 2 Florian 'branleb' Zumkeller-Quast 2011-01-18 11:49:46 UTC
Created attachment 56161 [details]
the last parsed file according to the stdout
Comment 3 Florian 'branleb' Zumkeller-Quast 2011-01-18 11:52:32 UTC
Created attachment 56162 [details]
the last lines of the stdout describing the crash
Comment 4 Milian Wolff 2011-01-18 12:44:15 UTC
the crash is in the PHP plugin, you attached a HTML file that gets parsed from the CSS plugin.

Either provide more stdout + the last php file or the full project. Or install more debug infos so I can find out where it actually cases in the type builder.

Also please paste backtraces etc. pp. instead of attaching them in the future.
Comment 5 Florian 'branleb' Zumkeller-Quast 2011-01-18 14:29:03 UTC
(In reply to comment #4)
> the crash is in the PHP plugin, you attached a HTML file that gets parsed from
> the CSS plugin.
The output doesn't look like this to me.
But if you are sure that the cause is the php plugin ...

> Either provide more stdout + the last php file or the full project. Or install
> more debug infos so I can find out where it actually cases in the type
> builder.
The whole project has more than one million LOC and is proprietary, therefore i can't supply its sources here.

If you could tell me how to make the debug output from the php plugin more verbose that I can see which file causes the error I could supply the code that causes the crash.
Up to know, I get some "Error: expected symbol" messages with a token and a line offset BUT no filename. Thus I can't upload the code snippet which causes this crash.
 
> Also please paste backtraces etc. pp. instead of attaching them in the future.
 I got used to the demand that thias should be attached to a ticket, but i will paste it here in the futue...
Comment 6 Milian Wolff 2011-01-18 15:08:08 UTC
search for [KCrash Handler] in your backtrace and you'll see that it crashes in php. Anyways, just show more lines of the stdout, it should also contain something like "kdevelop(9043)/php support Php::ParseJob::run: parsing URL", the last file(s) it talks about is what I need. Or - as I said - more debug symbols. Ask the gentoo/portage/emerge guys on how to compile in debugfull mode. Maybe just change the cmake-invokation to add this.
Comment 7 Florian 'branleb' Zumkeller-Quast 2011-01-18 16:30:58 UTC
After recompiling with debug enabled and some trace i think i found the reason
for the crash:

<?php
use \Name\Space\Class as SpecialClass;
?>

with a leading \ while using "use NS" lets kdevelop crash.

milian confirmed the behaviour in the irc channel.
Comment 8 Milian Wolff 2011-01-18 18:58:51 UTC
I'll hope to fix that later today
Comment 9 Milian Wolff 2011-01-18 20:13:57 UTC
commit 73042f2d574641f76f1ebcb87a54c457b6a72d00
branch 1.2
Author: Milian Wolff <mail@milianw.de>
Date:   Tue Jan 18 20:12:29 2011 +0100

    prevent explicitlyGlobal import identifiers for namespace alias declaration, fixes assert
    
    BUG: 263532

diff --git a/duchain/builders/declarationbuilder.cpp b/duchain/builders/declarationbuilder.cpp
index aae6073..6f5c0a4 100644
--- a/duchain/builders/declarationbuilder.cpp
+++ b/duchain/builders/declarationbuilder.cpp
@@ -1158,7 +1158,10 @@ void DeclarationBuilder::visitUseNamespace(UseNamespaceAst* node)
                                                                                 m_editor->findRange(idNode));
     {
         ///TODO: case insensitive!
-        decl->setImportIdentifier( identifierForNamespace(node->identifier, m_editor) );
+        QualifiedIdentifier qid = identifierForNamespace(node->identifier, m_editor);
+        ///TODO: find out why this must be done (see mail to kdevelop-devel on jan 18th 2011)
+        qid.setExplicitlyGlobal( false );
+        decl->setImportIdentifier( qid );
         decl->setPrettyName( id.first );
         decl->setKind(Declaration::NamespaceAlias);
     }
diff --git a/duchain/tests/duchain.cpp b/duchain/tests/duchain.cpp
index b3b9903..c83a65d 100644
--- a/duchain/tests/duchain.cpp
+++ b/duchain/tests/duchain.cpp
@@ -2405,13 +2405,14 @@ void TestDUChain::useNamespace()
                               "}\n"
                               "namespace {\n"
                               "use ns1\\ns2, ns3\\ns4 as ns5;\n"
+                              "use \\ns3\\ns4 as ns6;\n"
                               "}\n"
                               , DumpNone);
     QVERIFY(top);
     DUChainReleaser releaseTop(top);
     DUChainWriteLocker lock;
 
-    QCOMPARE(top->localDeclarations().count(), 4);
+    QCOMPARE(top->localDeclarations().count(), 5);
 
     Declaration* dec = top->localDeclarations().at(2);
     QCOMPARE(dec->qualifiedIdentifier().toString(), QString("ns2"));
@@ -2420,6 +2421,12 @@ void TestDUChain::useNamespace()
     dec = top->localDeclarations().at(3);
     QCOMPARE(dec->qualifiedIdentifier().toString(), QString("ns5"));
     QVERIFY(dynamic_cast<NamespaceAliasDeclaration*>(dec));
+
+    dec = top->localDeclarations().at(4);
+    QCOMPARE(dec->qualifiedIdentifier().toString(), QString("ns6"));
+    QVERIFY(dynamic_cast<NamespaceAliasDeclaration*>(dec));
+    ///TODO: find out why this is explictly required
+    QVERIFY(!dynamic_cast<NamespaceAliasDeclaration*>(dec)->importIdentifier().explicitlyGlobal());
 }
 
 struct TestUse {