[plt-scheme] drscheme in Xorg-7.0?

From: Paulo J. Matos (pocmatos at gmail.com)
Date: Mon Apr 10 03:21:59 EDT 2006

On 09/04/06, Paulo J. Matos <pocmatos at gmail.com> wrote:
> On 09/04/06, Paulo J. Matos <pocmatos at gmail.com> wrote:
> > On 17/03/06, Williams, M. Douglas <M.DOUGLAS.WILLIAMS at saic.com> wrote:
> > > I downloaded VMWare player (from http://www.vmware.com/) and followed the
> > > instructions at
> > > http://www.ffnn.nl/pages/articles/linux/vmware-player-image-creation.php to
> > > create an Ubuntu Dapper Drake Flight 5 VM.  This is all freeware and uses
> > > Xorg-7.0.  I loaded PLT Scheme 301.9 and it loads and runs fine.
> > >
> >
> > Was there any solution to this issue?
> > Working with Gentoo Linux here, updated to xorg7, and recompiler
> > drscheme 301.12, I also get a sigsegv. Here's some debug info:
> > Program received signal SIGSEGV, Segmentation fault.
> > [Switching to Thread -1215768912 (LWP 20597)]
> > 0x08291059 in wxWindowDC::SetFont (this=0x94d86c0, font=0x8510dc0)
> >     at WindowDC.cc:2680
> > 2680        XSetFont(DPY, TEXT_GC, xfs->fid);
> > (gdb) bt
> > #0  0x08291059 in wxWindowDC::SetFont (this=0x94d86c0, font=0x8510dc0)
> >     at WindowDC.cc:2680
> > #1  0x0824f14e in wxStyle::SwitchTo (this=0xa593d20, dc=0x94d86c0,
> >     oldStyle=0x0) at wx_style.cxx:906
> > #2  0x08268653 in wxMediaEdit::Redraw (this=0x97507f8, dc=0x94d86c0, starty=0,
> >     endy=4, leftx=0, rightx=4, dy=-0, dx=-0, show_caret=<value optimized out>,
> >     show_xsel=0, bgColor=0x8535d80) at wx_mpriv.cxx:2152
> > #3  0x08269b70 in wxMediaEdit::Refresh (this=0x97507f8, left=0, top=0,
> >     width=4, height=4, show_caret=1, bgColor=0x8535d80) at wx_mpriv.cxx:2616
> > #4  0x0820330f in os_wxMediaEdit::Refresh (this=0x97507f8, x0=0, x1=0, x2=4,
> >     x3=4, x4=1, x5=0x8535d80) at wxs_mede.cxx:3563
> > #5  0x08277c93 in wxMediaCanvas::Redraw (this=0xb093af8, localx=0, localy=0,
> >     fw=4, fh=4) at wx_medad.cxx:840
> > #6  0x08277d7e in wxMediaCanvas::OnPaint (this=0xb093af8) at wx_medad.cxx:666
> > #7  0x081f728f in os_wxMediaCanvasOnPaint (n=1, p=0x92a7198)
> >     at wxs_madm.cxx:756
> > #8  0x080c419d in _scheme_tail_apply_from_native (rator=0x874fb10, argc=1,
> >     argv=0x92a7198) at schnapp.inc:19
> >
> > DrScheme seems to be the only application failing... I'm running xorg
> > 7 for 24 hours now with a lot of different apps.
> >
> > Any ideas?
> >
>
> Some more debug info:
> On the SetFont function where is breaks:
> void wxWindowDC::SetFont(wxFont *font)
> {
>     XFontStruct *xfs;
>
>     if (!DRAWABLE)
>         return;
>
>     if (!(current_font = font)) // nothing to do without a font
>         return;
>
>     xfs  =(XFontStruct*)font->GetInternalFont(scale_x, scale_y);
>
>     if(!xfs)
>       printf("xfs pointer is null\n");
>
>     XSetFont(DPY, TEXT_GC, xfs->fid);
> }
>
> I added the printf line.
> Note that the function is called a lot of times and it breaks due to
> the fact that xfs is NULL. So for some reason GetInternalFont is
> returning NULL.
>

Even more debug info... It's quite a pain not to be able to work with
DrScheme at all... I need it! :)
So, yes, I'll only stop once this is solved! heh

I've traced this back to Font.cc wxLoadQueryNearestFont. I've added
some asserts and printfs along the way so I have this:
static XFontStruct *wxLoadQueryNearestFont(const char *name, /* LINE 926*/
					   int point_size, double scale_x, double scale_y,
					   int fontid, int family,
					   int style, int weight,
					   Bool underlined, Bool sip, double angle)
{
  XFontStruct *font;
  int tried_once = 0;

  while (1) {

    font = wxLoadQueryFont(name, point_size, scale_x, scale_y,
			   fontid, style, weight, underlined,
			   1, sip, angle);

    if (!font) {
      // search up and down by stepsize 1
      int max_size = point_size + 2 * (1 + (point_size/18));
      int min_size = point_size - 2 * (1 + (point_size/18));
      int i;

      // Try plain style
      font = wxLoadQueryFont(NULL, point_size, scale_x, scale_y,
			     fontid, wxNORMAL, wxNORMAL_WEIGHT, underlined,
			     1, sip, angle);

      // Search for smaller size (approx.)
      for (i=point_size-1; !font && i >= 1 && i >= min_size; i -= 1) {
	font = wxLoadQueryFont(name, i, scale_x, scale_y,
			       fontid, style, weight, underlined,
			       1, sip, angle);
	if (!font)
	  font = wxLoadQueryFont(NULL, i, scale_x, scale_y, fontid,
				 wxNORMAL, wxNORMAL_WEIGHT, underlined,
				 1, sip, angle);
      }
      // Search for larger size (approx.)
      for (i=point_size+1; !font && i <= max_size; i += 1) {
	font = wxLoadQueryFont(name, i, scale_x, scale_y,
			       fontid, style, weight, underlined,
			       1, sip, angle);
	if (!font)
	  font = wxLoadQueryFont(NULL, i, scale_x, scale_y,
				 fontid,  wxNORMAL, wxNORMAL_WEIGHT, underlined,
				 1, sip, angle);
      }
    }

    if (font || tried_once)
      break;
    else {
      tried_once = 1;
      fontid = family;
    }
  }

  /* Last-ditch efforts */
  if (!font) {
    printf("On last-ditch efforts to find a font.\n");
    char buffer[40];
    sprintf(buffer, "-*-*-*-*-*-*-*-%d-*-*-*-*-*-*", point_size * 10);
    font = XLoadQueryFont(wxAPP_DISPLAY, buffer);

    if (!font) /* really last-ditch */ {
      printf("REALLY LAST DITCH!\n");
      font = XLoadQueryFont(wxAPP_DISPLAY, "-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
    }
  }

  assert(font);
  return font;
} /* LINE 997 */

The program enters this last ditch efforst and even the really
last-ditch and fails...  Which means that:
font = XLoadQueryFont(wxAPP_DISPLAY, "-*-*-*-*-*-*-*-*-*-*-*-*-*-*");

I do not have a solution since I do not know what
"-*-*-*-*-*-*-*-*-*-*-*-*-*-*" means but from the XLoadQueryFont man
page:
XLoadQueryFont can generate a BadAlloc error.

       The XLoadQueryFont function provides the most common way for accessing
       a font.  XLoadQueryFont both opens (loads) the specified font and
       returns a pointer to the appropriate XFontStruct structure.  If the
       font name is not in the Host Portable Character Encoding, the result is
       implementation-dependent.  If the font does not exist, XLoadQueryFont
       returns NULL.

Shouldn't DrScheme check at least for the NULL return value? It would
be easier to debug in this cases.

Any ideas what to look for next? It's weird I'm missing a font since I
have all of the fonts available from Gentoo Portage installed... and
haven't changed xorg.conf during the xorg7 upgrade!

> > > Doug
> > >
> > >
> > > -----Original Message-----
> > > From: plt-scheme-bounces at list.cs.brown.edu on behalf of Matthew Flatt
> > > Sent: Thu 3/16/2006 7:26 PM
> > > To: Patrick McLean
> > > Cc: plt-scheme at list.cs.brown.edu
> > > Subject: Re: [plt-scheme] drscheme in Xorg-7.0?
> > >
> > > That would be great - thanks.
> > >
> > > Matthew
> > >
> > > At Thu, 16 Mar 2006 21:20:03 -0500, Patrick McLean wrote:
> > > > I could make a tarball that could be unzipped into a virtual machine (like
> > > > vmware) so you wouldn't have to compile a full Gentoo system.
> > > >
> > > > Matthew Flatt wrote:
> > > > > Can anyone recommend a simple way of setting up a (virtual) machine
> > > > > that will make DrScheme crash?
> > > > >
> > > > > I'm hoping for something that's easier than starting a Gentoo
> > > > > installation from scratch...
> > > >
> > > > _________________________________________________
> > > >   For list-related administrative tasks:
> > > >   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> > > _________________________________________________
> > >   For list-related administrative tasks:
> > >   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> > >
> > > _________________________________________________
> > >   For list-related administrative tasks:
> > >   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> > >
> >
> >
> > --
> > Paulo Jorge Matos - pocm at sat inesc-id pt
> > Web: http://sat.inesc-id.pt/~pocm
> > Computer and Software Engineering
> > INESC-ID - SAT Group
> >
>
>
> --
> Paulo Jorge Matos - pocm at sat inesc-id pt
> Web: http://sat.inesc-id.pt/~pocm
> Computer and Software Engineering
> INESC-ID - SAT Group
>


--
Paulo Jorge Matos - pocm at sat inesc-id pt
Web: http://sat.inesc-id.pt/~pocm
Computer and Software Engineering
INESC-ID - SAT Group


Posted on the users mailing list.