Subject: fvwm-themes, crash when loading awol theme

From: Mike Fabian <[email-masked]>
Date: 26 Apr 2001 19:08:22 +0200

Mikhael Goikhman <[email-masked]> writes:

> On 25 Apr 2001 16:16:40 +0200, Mike Fabian wrote:
> > 
> > any ideas what causes this crash of fvwm2 when I try to switch to the
> > "awol" theme?
> > 
> >     ~/.fvwm$ WINDOWMANAGER=fvwm-themes-start startx -- :2
> > 
> >     [...]
> > 
> >     BUG: (AllocNonlinearGradient): i = 0, curpixel = 0, seg_end_colors[i] = -2147483648
> > 
> >    ~/.fvwm$ file core
> >     core: ELF 32-bit LSB core file of 'fvwm2' (signal 6), Intel 80386, version 1, from 'fvwm2'
> > 
> > The other themes seem to work fine, I get the crash only when
> > switching to the "awol" theme.
> 
> It is probably possible to narrow the problem, don't load the entire awol
> theme, load component by component and tell which one is problematic (the
> problematic line in this component would be nice too). I guess it is
> colors@awol, presumably YGradient line.

Yes, I can load all other components of the awol theme, but fvwm2
crashes when I click on the colors component of the awol theme.

How to find out the problematic line?

> Can you please also send (better to fvwm-workers) the core stack

> and some info about your screen (depth, resolution). Thank you.

resolution 1600x1200, depth 16.

output of xdpyinfo:

-- 
Mike Fabian   <[email-masked]>   http://www.suse.de/~mfabian
睡眠不足はいい仕事の敵だ。

---

From: Mikhael Goikhman <[email-masked]>
Date: Thu, 26 Apr 2001 19:14:50 -0500

> How to find out the problematic line?

By running commands line by line from themes/awol/colors in FvwmConsole? :)

Maybe this line crashes your fvwm (other colorset lines are pretty common):

*FvwmTheme: Colorset 16 fg black, bg average, \
	YGradient 400 3 cyan4 100 cyan1 1 cyan4 100 cyan1, NoShape

> > Can you please also send (better to fvwm-workers) the core stack

Somehow I don't think this stack is useful, fvwm was not compiled with -g.

I believe Tim or Dominik may say more about this
"BUG: (AllocNonlinearGradient): i = 0 ..." message in libs/Graphics.c.

> resolution 1600x1200, depth 16.

Regards,
Mikhael.
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Dan Espen <[email-masked]>
Date: Thu, 26 Apr 2001 21:31:24 -0400

> Somehow I don't think this stack is useful, fvwm was not compiled with -g.

The stack isn't useful because the gradient logic calls abort() causing
the dump.  Check line 316, libs/Graphics.c.

Seems like the wrong thing to do to me, abort() seems pretty drastic for
a drawing logic problem.

> "BUG: (AllocNonlinearGradient): i = 0 ..." message in libs/Graphics.c.

If I try to understand it, my head might hurt.

-- 
Dan Espen
444 Hoes Lane  Room RRC 1C-214           E-mail: [email-masked]
Piscataway, NJ 08854                     Phone: (732) 699-5570
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Dan Espen <[email-masked]>
Date: Thu, 26 Apr 2001 23:04:38 -0400

> If I try to understand it, my head might hurt.

Ok, I'm wrong, its not that hard to understand.

A gradient like this:

would print i=0 curpixel 199 seg_end_colors[i] = 199,
the abort   has curpixel   0 seg_end_colors[i] = -2147483648

Mike, can you add this:

    fprintf(stderr,
    "nsegs %d, i %d, curpixel %d, seg_end_colors[i] = %d, npixels %d, n %d\n",
            nsegs, i, curpixel,
            seg_end_colors[i],npixels,n);

to libs/Graphics.c around line 352, just before this:

if (curpixel != seg_end_colors[i])

That might help to identify the gradient and give a clue to whats
happening.

I'be never worked with "alloca()".  Heres what Sun's man page says
about it:

     The alloca() function is machine-, compiler-,  and  most  of
     all, system-dependent. Its use is strongly discouraged.

Any chance alloca could be malfunctioning?

---

From: Mike Fabian <[email-masked]>
Date: 27 Apr 2001 12:13:08 +0200

> if (curpixel != seg_end_colors[i])

Gives the output:

    [FVWM-Themes]: Starting FVWM under the main fvwm-themes session
    nsegs 3, i 0, curpixel 0, seg_end_colors[i] = -2147483648, npixels 128, n -2147483647
    BUG: (AllocNonlinearGradient): i = 0, curpixel = 0, seg_end_colors[i] = -2147483648

    waiting for X server to shut down kterm:  fatal IO error 32 (パイプが切断されました) or KillClient on X server ":2.0"

By the way, I tried to compile fvwm with "-O0 -g", to produce a better
readable stack as requested by Mikhael Goikhman.  But a fvwm compiled
with "-O0 -g" does *not* crash anymore when loading the awol theme!

---

From: Mike Fabian <[email-masked]>
Date: 27 Apr 2001 12:33:24 +0200

> 	YGradient 400 3 cyan4 100 cyan1 1 cyan4 100 cyan1, NoShape

This line only doesn't crash my FVWM. As you suggested, I did run
all the commands from themes/awol/colors line by line from FvwmConsole.
FVWM did not crash. But clicking on

   Theme management -> awol -> colors

crashes FVWM.

---

From: Dan Espen <[email-masked]>
Date: Fri, 27 Apr 2001 07:16:40 -0400

>     nsegs 3, i 0, curpixel 0, seg_end_colors[i] = -2147483648, npixels 128, n

The number of segments and number of pixels match up with
the YGradient.

> with "-O0 -g" does *not* crash anymore when loading the awol theme!

Sounds like a possible compiler bug.

Right after line 312:
      seg_end_colors[i] = (int)(color_sum + 0.5);

Add this:
      fprintf(stderr,
              "seg_end_colors %X, color_sum %f, i %d, clen[i] %d"
              " npixels %d, seg_sum %d seg_end_colors[i] %d\n",
              seg_end_colors,color_sum, i, clen[i], npixels, seg_sum,
              seg_end_colors[i]);

On my system I get:

seg_end_colors FFBEC0F8, color_sum 198.507462, i 0, clen[i] 100 npixels 400, seg_sum 201 seg_end_colors[i] 199
seg_end_colors FFBEC0F8, color_sum 200.492538, i 1, clen[i] 1 npixels 400, seg_sum 201 seg_end_colors[i] 200
seg_end_colors FFBEC0F8, color_sum 399.000000, i 2, clen[i] 100 npixels 400, seg_sum 201 seg_end_colors[i] 399
nsegs 3, i 0, curpixel 199, seg_end_colors[i] = 199, npixels 400, n 200
nsegs 3, i 1, curpixel 200, seg_end_colors[i] = 200, npixels 400, n 2
nsegs 3, i 2, curpixel 399, seg_end_colors[i] = 399, npixels 400, n 200

I think this will reveal the problem.

---

From: Mike Fabian <[email-masked]>
Date: 27 Apr 2001 17:55:04 +0200

> I think this will reveal the problem.

On my system:

    [FVWM-Themes]: Welcome to FVWM Themes 0.4.2!
    [FVWM-Themes]: Starting FVWM under the main fvwm-themes session
    nsegs 1, i 0, curpixel 19, seg_end_colors[i] = 19, npixels 20, n 20
    seg_end_colors BFFFDA94, color_sum nan, i 0, clen[i] 1000 npixels 128, seg_sum 2001 seg_end_colors[i] -2147483648
    seg_end_colors BFFFDA94, color_sum nan, i 1, clen[i] 1 npixels 128, seg_sum 2001 seg_end_colors[i] -2147483648
    seg_end_colors BFFFDA94, color_sum nan, i 2, clen[i] 1000 npixels 128, seg_sum 2001 seg_end_colors[i] -2147483648
    nsegs 3, i 0, curpixel 0, seg_end_colors[i] = -2147483648, npixels 128, n -2147483647
    BUG: (AllocNonlinearGradient): i = 0, curpixel = 0, seg_end_colors[i] = -2147483648

"color_sum nam" is strange, isn't it?

---

From: Dan Espen <[email-masked]>
Date: Fri, 27 Apr 2001 15:09:14 -0400

Mike Fabian <[email-masked]> writes:
> > > >     "nsegs %d, i %d, curpixel %d, seg_end_colors[i] = %d, npixels %d, n
>  %d\
> > > n",
> > > >             nsegs, i, curpixel,
> > >     nsegs 3, i 0, curpixel 0, seg_end_colors[i] = -2147483648, npixels 12
> 8, n
> > >  -2147483647
> > >     BUG: (AllocNonlinearGradient): i = 0, curpixel = 0, seg_end_colors[i]
>  = -
> > > 2147483648
> > 

This one looks like a complex gradient with one segment.  I think it got
handled OK.

>     nsegs 3, i 0, curpixel 0, seg_end_colors[i] = -2147483648, npixels 128, n

This doesn't look like the gradient I thought it was.
It has 3 segments, 128 colors, and 1000, 1, 1000 as its respective numbers
of colors.

>     waiting for X server to shut down kterm:  fatal IO error 32 (パイプが切
�断されました) or KillClient on X server ":2.0"
> 
> "color_sum nan" is strange, isn't it?

It means "not a number".

I  think something is going  out of range, but I'm  not well versed in
using floating point math on computers.  Gotta do some reading.

Anyone from FvwmThemes recognize the gradient?

---

From: Mikhael Goikhman <[email-masked]>
Date: Fri, 27 Apr 2001 22:53:34 +0000

> >     [FVWM-Themes]: Welcome to FVWM Themes 0.4.2!

Off topic. You should delete ~/.fvwm/themes* to get the greeting again. :)
This is a good solution to fight the core dump, but I myself in this
situation would run (before running X) one of these:

  % fvwm-themes-config --reset
  % fvwm-themes-config --load colors@cde

> >     waiting for X server to shut down kterm:  fatal IO error 32 ($B%Q%$%W$,@Z
> > CG$5$l$^$7$?(B) or KillClient on X server ":2.0"
> > 

% grep Gradient themes/awol/colors
TitleStyle ActiveDown HGradient 128 3 Blue 1000 Green 1 Yellow 1000 Red
TitleStyle ToggledActiveDown HGradient 128 3 Blue 1000 Green 1 Yellow 1000 Red
	YGradient 400 3 cyan4 100 cyan1 1 cyan4 100 cyan1, NoShape

Regards,
Mikhael.

---

From: Dan Espen <[email-masked]>
Date: Sat, 28 Apr 2001 14:35:27 -0400

> > Dan Espen <[email-masked]> writes:
...

Mike and I exchanged some offline mails.

I still suspect a gcc or libc bug.  I don't see anything wrong
with the calculations in fvwm other than the rather extreme reaction
(the abort), which I just replaced with a warning message.