Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#11 Segfault opening file on command line

closed-accepted
nobody
None
5
2004-07-02
2004-03-08
Stevan White
No

Segfaults when opening a file on command line, but not
when open from the menu. The file is very big.

This is Mandrake 9.1; KDE 3.1.3.

In both cases, raises a dialog:
Exited with error(s)
dot could not display the data (1).

But when open from menu, proceeds to display the data.

Compiled with debugging on. Lots of stufg goes to
stderr in either case.
Lots of
kprof: kprofwidget.cpp(1460) TRC
static QString
KProfWidget::getClassName(const QString&) {
kprof: kprofwidget.cpp(1519) TRC }

then a few
ASSERT: "i <= nodes" in
/usr/lib/qt3/include/qvaluelist.h (372)
then lots of
kprof: kprofwidget.cpp(1528) TRC
QString
KProfWidget::removeTemplates(const QString&) {
kprof: kprofwidget.cpp(1530) TRC }

In GDB:

(KListView*, int) {
kprof: kprofwidget.cpp( 442) TRC }
kprof: kprofwidget.cpp(1593) TRC void
KProfWidget::prepareHtmlPart(KHTMLPart*) {
QFile::writeBlock: File not open
kprof: kprof.cpp( 132) TRC
virtual bool KProfTopLevel::queryExit() {

Program received signal SIGSEGV, Segmentation fault.
0x4089f5cb in KRecentFilesAction::saveEntries(KConfig*,
QString) ()
from /usr/lib/libkdeui.so.4
(gdb) bt
#0 0x4089f5cb in
KRecentFilesAction::saveEntries(KConfig*, QString) ()
from /usr/lib/libkdeui.so.4

The backtrace from the KBacktrace seems uninformative:
0x414d4656 in waitpid () from /lib/i686/libpthread.so.0
#0 0x414d4656 in waitpid () from /lib/i686/libpthread.so.0
#1 0x40af8fda in KCrash::defaultCrashHandler(int) ()
from /usr/lib/libkdecore.so.4

Discussion

  • Colin Desmond
    Colin Desmond
    2004-04-06

    Logged In: YES
    user_id=556235

    Have you managed to run this successfully on other files? Do
    you have the GraphViz library (includes dot) installed?

    Colin

     
  • Ben Burton
    Ben Burton
    2004-06-19

    Logged In: YES
    user_id=146613

    Hi. I believe I've solved this problem (it was reported in the Debian
    BTS also). The command-line args are being parsed before the main
    window is fully constructed, and if this command-line parsing throws up
    a message box then kprof can crash.

    I'm guessing it's because the message box closing makes KDE think
    the last window is closing, at which point kprof tries to exit --
    unfortunately the main window is still in a half-state, seeing as we're
    still only right near the beginning of the KProfTopLevel constructor.
    Amongst other things, it tries to save the list of recent files before it's
    read them, leading to the SIGSEGV. At least that's my guess.

    You can see this same problem by passing an invalid -f argument.
    e.g., "kprof -f /bin/ls". It throws a message box saying it can't find any
    valid profiling data, and then it crashes. (This was the symptom
    reported in the debian bug.)

    At any rate: waiting until the main window is fully constructed before
    parsing the cmdline args fixes the problem for me. I've just committed
    the changes to kprof CVS; the patch is also included below for anyone
    else who is interested.

    Ben. :)

     
  • Ben Burton
    Ben Burton
    2004-06-19

    Logged In: YES
    user_id=146613

    Hmm, well sf.net won't let me attach a file. So here's the patch as a
    text comment. Hope it gets formatted okay in the bug log.

    Index: kprof/kprof.cpp

    RCS file: /cvsroot/kprof/kprof/kprof/kprof.cpp,v
    retrieving revision 1.18
    diff -u -3 -p -r1.18 kprof.cpp
    --- kprof/kprof.cpp 29 Oct 2002 21:50:26 -0000 1.18
    +++ kprof/kprof.cpp 19 Jun 2004 05:18:03 -0000
    @@ -59,6 +59,10 @@ KProfTopLevel::KProfTopLevel (QWidget *p

    loadSettings ();
    applySettings ();
    +
    + RUN("process command line args");
    + mProf->openCommandLineFiles ();
    +
    END;
    }

    Index: kprof/kprofwidget.cpp

    RCS file: /cvsroot/kprof/kprof/kprof/kprofwidget.cpp,v
    retrieving revision 1.53
    diff -u -3 -p -r1.53 kprofwidget.cpp
    --- kprof/kprofwidget.cpp 29 Oct 2002 21:52:01 -0000 1.53
    +++ kprof/kprofwidget.cpp 19 Jun 2004 05:18:04 -0000
    @@ -206,23 +206,6 @@ KProfWidget::KProfWidget (QWidget *paren

    mConfigure = new CConfigure(this);

    - //Now that the interface has been set up, parse the command line
    - //arguments
    -
    - RUN("process command line args");
    - KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    - QString fileName = "";
    - ProfilerEnumeration prof = FORMAT_GPROF;
    - bool argsToUse = parseArguments(args, fileName, prof);
    - args->clear();
    -
    - //If the file name has been set in the command line arguments
    - //then open the file with the chosen profiler.
    - if (argsToUse && (fileName != ""))
    - {
    - openFile(fileName, prof, false);
    - }
    -
    END;
    }

    @@ -610,6 +593,26 @@ void KProfWidget::openResultsFile ()
    END;
    }

    +void KProfWidget::openCommandLineFiles ()
    +{
    + BEGIN;
    +
    + KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    + QString fileName = "";
    + ProfilerEnumeration prof = FORMAT_GPROF;
    + bool argsToUse = parseArguments(args, fileName, prof);
    + args->clear();
    +
    + //If the file name has been set in the command line arguments
    + //then open the file with the chosen profiler.
    + if (argsToUse && (fileName != ""))
    + {
    + openFile(fileName, prof, false);
    + }
    +
    + END;
    +}
    +
    void KProfWidget::openFile (const QString &filename,
    ProfilerEnumeration format, bool compare)
    {
    BEGIN;
    Index: kprof/kprofwidget.h
    ===================================================================
    RCS file: /cvsroot/kprof/kprof/kprof/kprofwidget.h,v
    retrieving revision 1.34
    diff -u -3 -p -r1.34 kprofwidget.h
    --- kprof/kprofwidget.h 29 Oct 2002 21:52:01 -0000 1.34
    +++ kprof/kprofwidget.h 19 Jun 2004 05:18:04 -0000
    @@ -172,6 +172,7 @@ public slots:
    void openResultsFile ();
    void compareFile ();
    void openRecentFile (const KURL& url);
    + void openCommandLineFiles ();
    void doPrint ();

    void profileEntryRightClick (QListViewItem *listItem, const QPoint
    &p, int);

     
  • Colin Desmond
    Colin Desmond
    2004-07-02

    • status: open --> open-accepted
     
  • Colin Desmond
    Colin Desmond
    2004-07-02

    • status: open-accepted --> closed-accepted