After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 372671 - Turning on loglog smoothing crashes FractalExplorer.
Turning on loglog smoothing crashes FractalExplorer.
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Plugins
git master
Other All
: Normal normal
: 2.2
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2006-11-08 21:30 UTC by Kevin Cozens
Modified: 2006-11-15 17:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for fixing this bug which implements the explanation in the previous comment (3.43 KB, patch)
2006-11-11 10:26 UTC, Mukund Sivaraman
reviewed Details | Review

Description Kevin Cozens 2006-11-08 21:30:37 UTC
As soon as you click the box beside "Use loglog smoothing" on the Colors tab, Fractal Explorer will die with a segmentation fault. The problem is in the formula for 'adjust' in both the Dialogs.c and FractalExplorer.c files.

The formula is:
  adjust = log (log (x * x + y * y) / 2) / log (2);

The log (x * x + y * y) will return a 0 or negative value for certain combinations of x and y. This will result in adjust being set to 'nan' (ie. not a number) when this value is passed to the outer log call.

The segmentation fault occurs a few lines down when an array lookup is performed based on an offset calculated using the bad value of adjust.
Comment 1 Sven Neumann 2006-11-09 08:50:17 UTC
Given this analysis, it should be easy to fix the bug. Kevin, is is right to assume that you are already working on a fix?
Comment 2 Kevin Cozens 2006-11-10 19:18:15 UTC
I tried a simple fix of setting adjust to 0 if the result of the first log is less than or equal to 0 but it causes noticeable (and not particaularly good) changes in the generated image. It would prevent the segfault so it may be worth making this change until a better fix comes along.
Comment 3 Mukund Sivaraman 2006-11-11 10:25:10 UTC
The crash occurs because floating point "inf" is used for array index calculations. This inf is generated by the log(log(modulus)), when modulus < e
(the base for natuaral logarithms).

modulus is < 4 when the innermost loop exits after the entire loop has run, i.e., it doesn't break (the modulus doesn't cross the "escape" radius of 2). The loop has a counter so we don't wait indefinitely for the modulus to escape. So there's a maximum value for this counter (called the loop counter).

If the loop has exited after a full run, it already means that the loop counter is clamped at the maximum value. So mu (alpha) can be equal to 0.0. This region represents the entire innermost lake of the mandelbrot set.

We basically check if modulus < e and use alpha = 0.0. Even if e <= modulus < 4, log(log(modulus)) will return a very small (non-negative) real number which won't affect the colormap index.

Patch is attached below. But we won't use this patch as we'll first clean up the Fractal Explorer plug-in a bit to remove redundant code.

Comment 4 Mukund Sivaraman 2006-11-11 10:26:13 UTC
Created attachment 76377 [details] [review]
Patch for fixing this bug which implements the explanation in the previous comment
Comment 5 Mukund Sivaraman 2006-11-11 10:28:30 UTC
No loglog:
http://www.mukund.org/temp/mandel-plain.png

loglog:
http://www.mukund.org/temp/mandel-loglog.png

Comment 6 Sven Neumann 2006-11-14 11:55:50 UTC
Please use G_E instead of defining M_E. And I would prefer if you would commit this patch (after changing to G_E) before you proceed cleaning up the code. It's better to have multiple smaller commits than one large one.
Comment 7 Kevin Cozens 2006-11-14 21:32:07 UTC
2006-11-15  Mukund Sivaraman  <muks@mukund.org>

        * plug-ins/FractalExplorer/FractalExplorer.c
        * plug-ins/FractalExplorer/Dialogs.c: Fixed bug #372671 and made
        loglog smoothing work again.

Closing this bug since the bug originally reported has been fixed.
Comment 8 Sven Neumann 2006-11-15 17:05:48 UTC
Fix was merged into the gimp-2-2 branch.