Hello all,

In my FLTK application, I'm getting a segfault.

Running the program, this is part of
the output I get:

[...]
generated catalog
deleting old buffer
appending new cat
Contents=
      Catalog timestamp      : Wed 2009-06-17 19:26:58 BST
      Volume name            :
      Number of projects     : 0

Segmentation fault

This is the relevant code snippet generating the segfault:
-------------
/* to prevent re-refresh by selecting current project
    which will select a song which will refresh the current
    ui again...(in case of corrupt 'unexpected end of song'
    songs): */
if (refreshingui>1) return;
refreshingui++;

// init dropdown lists.
#if (HD24DEBUG==1)
cout << "going to clear dropdown lists" << endl;
#endif
if (projectname!=NULL)
{
   for (unsigned int q=0;q<=99;q++)
   {
        projectname->remove(0);
   }
}
if (songname!=NULL)
{
   for (unsigned int q=0;q<=99;q++)
   {
        songname->remove(0);
   }
}

#if (HD24DEBUG==1)
cout << "going to populate drive list" << endl;
#endif
populate_drivelist(0);

// following uses fsys (the default drive)
#if (HD24DEBUG==1)
cout << "get projcount then?" << endl;
#endif
string* nump=Convert::int2str(currenthd24->projectcount());
#if (HD24DEBUG==1)
cout << "got projcount=" << *nump <<  endl;
#endif
number_of_projects->value(nump->c_str());
delete (nump);
#if (HD24DEBUG==1)
cout << "last project id=" << currenthd24->lastprojectid() << endl;
#endif

populate_projectlist(currenthd24->lastprojectid());
#if (HD24DEBUG==1)
cout << "project list populated." << endl;
#endif


string* cat=new string("");
#if (HD24DEBUG==1)
cout << "updating gui TOC" << endl;
#endif

if (hd24utils::gencatalog(this->currenthd24,cat)==0) {
#if (HD24DEBUG==1)
cout << "generated catalog" << endl;
#endif

#if (HD24DEBUG==1)
cout << "deleting old buffer" << endl;
#endif

        this->catalogbuffer->remove(0,this->catalogbuffer->length()-1);
#if (HD24DEBUG==1)
cout << "appending new cat" << endl;
cout << "Contents=" << endl;
cout << cat->c_str() << endl;
#endif
        this->catalogbuffer->append(cat->c_str());
}
#if (HD24DEBUG==1)
cout << "deleting catalog string" << endl;
#endif
delete(cat);
#if (HD24DEBUG==1)
cout << "get version" << endl;
#endif
string* version1=currenthd24->version();
#if (HD24DEBUG==1)
cout << "got version" << endl;
#endif
fsversion->value(version1->c_str());
delete(version1);

calcspace();
refreshingui--;
--

So it appears that the segfault occurs in the line

        this->catalogbuffer->append(cat->c_str());

With all of these defined as they should,
I'm at a loss.

Yesterday when I tried tracing with
gdb, the backtrace indicated a problem in XLoadQueryFont
(called through fl_font -> fl_xxfont if I recall
correctly)

I tried updating my 1.1.7 FLTK to 1.1.9 and still get
the same segfault, however when I try to run the program
through gdb now, I'm getting a segfault at a much earlier
stage.

My questions are:

1. What can I do about the segfault in XLoadQueryFont?
    Are there any known workarounds?
2. I'm currently compiling with -O0 (no optimizing at
    all), but the code runs differently when running
    in gdb instead of by itself, making it hard to see
    what the code is actually doing. Is there anything I
    can do about that?

Thanks in advance, 
Marc


_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to