Difference between revisions of "Hacking:Problems and solutions"

From GIMP Developer Wiki
Jump to: navigation, search
(Update)
(BABL: rework)
Line 8: Line 8:
  
 
===BABL===
 
===BABL===
'''Problem: Unit tests pass on one machine, but not on another - equally configured - machine.'''
+
'''Problem: Unit tests pass on one machine, but fail on another - equally configured - machine.'''
  
 
In this particular case the tests RGBA->HSLA and RGBA->HSVA passed on an amd64 platform, but failed on an i386 platform.
 
In this particular case the tests RGBA->HSLA and RGBA->HSVA passed on an amd64 platform, but failed on an i386 platform.
Content of file tests/testsuite.log on the i386 machine:
 
 
<code>
 
  
 +
This is the content of file tests/testsuite.log on the i386 machine:
  
 +
<pre>
 
babl 0.1.11: tests/test-suite.log
 
babl 0.1.11: tests/test-suite.log
 
+
=========
  
 
TOTAL: 19
 
TOTAL: 19
Line 48: Line 47:
  
 
rgba to hsva  failed #1[0]  got 0.166667 expected 0.000000
 
rgba to hsva  failed #1[0]  got 0.166667 expected 0.000000
 
+
</pre>
</code>
+
  
  
 
'''Cause:'''
 
'''Cause:'''
The tested code doesn't take into account that strict equality comparisons (==) can lead to different results on different platforms.
+
The tested code doesn't take into account that strict equality comparisons (==) will most often lead to different results on different platforms.
  
 
'''Solution:'''
 
'''Solution:'''
The code must take this fact into account. This means, DON'T USE == FOR FLOATING POINT COMPARISONS.
+
The code must take this fact into account. This means:
  
Also make sure, your code works on all archs. On a 64 bit machine this would mean also to compile and make check with CFLAGS="-O2 -mfpmath=387".
+
* '''Don't use == for floating point comparisons!'''
  
Make sure to have defined EPSILON first:  
+
The following lines show alternatives.
 +
 
 +
1. Make sure to have defined EPSILON first:  
  
 
<code>
 
<code>
Line 66: Line 66:
 
</code>
 
</code>
  
Here are some examples:
+
2. Use EPSILON instead of == :
  
 
{|class="wikitable" style="text-align:left;" border="1"
 
{|class="wikitable" style="text-align:left;" border="1"
Line 83: Line 83:
 
See also [https://git.gnome.org/browse/babl/commit/?id=da3b41274052c23b44ad8eceb9d99106d2739f3a Bugfix for RGBA->HSLA,HSVA conversions].
 
See also [https://git.gnome.org/browse/babl/commit/?id=da3b41274052c23b44ad8eceb9d99106d2739f3a Bugfix for RGBA->HSLA,HSVA conversions].
  
If you're unsure, come to IRC (#gimp or #gegl) and ask.
+
* Make sure, your code works on all architectures. On a 64 bit machine this would mean also to compile and run <code>make check</code> with '''CFLAGS="-O2 -mfpmath=387"'''.
 +
 
 +
If you're unsure, come to IRC (channels [irc://irc.gimp.org/gimp #gimp] or [irc://irc.gimp.org/gegl #gegl]) and ask.
  
 
===GEGL===
 
===GEGL===

Revision as of 11:44, 4 August 2013

This page describes problems that hamper the developers work and their solution. It's a knowledge base for developers. Feel free to add your own findings and don't be shy. It makes the work easier for all of us.


Building

BABL

Problem: Unit tests pass on one machine, but fail on another - equally configured - machine.

In this particular case the tests RGBA->HSLA and RGBA->HSVA passed on an amd64 platform, but failed on an i386 platform.

This is the content of file tests/testsuite.log on the i386 machine:

babl 0.1.11: tests/test-suite.log
=========

TOTAL: 19

PASS:  17

SKIP:  0

XFAIL: 0

FAIL:  2

XPASS: 0

ERROR: 0

.. contents:: :depth: 2

FAIL: hsl


rgba to hsla  failed #0[0]  got 0.166667 expected 0.000000

rgba to hsla  failed #1[0]  got 0.666667 expected 0.000000

FAIL: hsva


rgba to hsva  failed #0[0]  got 0.166667 expected 0.000000

rgba to hsva  failed #1[0]  got 0.166667 expected 0.000000


Cause: The tested code doesn't take into account that strict equality comparisons (==) will most often lead to different results on different platforms.

Solution: The code must take this fact into account. This means:

  • Don't use == for floating point comparisons!

The following lines show alternatives.

1. Make sure to have defined EPSILON first:

#define EPSILON 1.0e-10

2. Use EPSILON instead of == :

wrong right
if (value == 0.0) if (value < EPSILON)
if (value1 == value2) if (value1 - value2 < EPSILON) or

if (fabs (value1 - value2)) < EPSILON

See also Bugfix for RGBA->HSLA,HSVA conversions.

  • Make sure, your code works on all architectures. On a 64 bit machine this would mean also to compile and run make check with CFLAGS="-O2 -mfpmath=387".

If you're unsure, come to IRC (channels #gimp or #gegl) and ask.

GEGL

Problem: Building GEGL master stops with failing assertions related to GLib. The stopped build can't be aborted with Ctrl+C. to enter new commands in that terminal session.

The following messages are shown at the screen:

CC       gegl-matrix.lo
CCLD     libgegl-0.3.la
GISCAN Gegl-0.3.gir
GLib-GObject-CRITICAL **: gtype.c:2720: You forgot to call g_type_init()
GLib-GObject-CRITICAL **: g_type_interface_add_prerequisite: assertion `G_TYPE_IS_INTERFACE (interface_type)' failed
GLib-CRITICAL **: g_once_init_leave: assertion `result != 0' failed
GLib-GObject-CRITICAL **: gtype.c:2720: You forgot to call g_type_init()
GLib-CRITICAL **: g_once_init_leave: assertion `result != 0' failed
GLib-GObject-CRITICAL **: gtype.c:2720: You forgot to call g_type_init()
GLib-CRITICAL **: g_once_init_leave: assertion `result != 0' failed


Cause: You have an old GLib version in your prefix. (Don't be fooled by just looking at the libglib version in your package manager!)

Solution:

  1. Close this terminal session and open a new one.
  2. Remove that old GLib version from your prefix and rebuild GEGL from scratch.


GIMP

Problem: Building GIMP fails for instance in libgimpcolor with a message telling you, that some files in $ANOTHER_PREFIX/lib are missing and thus building libgimpcolor.la (or another *.la file) failed.

Cause: You switched over to another prefix. You already cleaned or removed that old prefix, but in your new prefix are some files referring to other files in that old prefix. In other words - there's an evil mixture of your new prefix and some old prefix zombies and libtool trips you up ;-)

Solution: Finding out the actually errorneous parts can take you hours, so it's better to make a clean sweep:

  1. Check your environment variables, especially the build environment variables. If they point to that old prefix, change them to point to the new prefix.
  2. Drop the contents of your new prefix.
  3. Rebuild from scratch. For BABL, GEGL and GIMP (and other libraries, if you use them):
    1. Change to their directory.
    2. Save your work (backup your working files or do git stash).
    3. Run git clean -xdf or drop the contents of the workspace except the .git folder or the source tarball.
    4. Run ./configure --prefix=$PREFIX (Git users: ./autogen.sh --prefix=$PREFIX).
    5. Run make && make install.

Some more information on building can be found at the building tutorials.

Debugging

Git

Problem: After checking out a particular branch, Git tells me, that I'm a few commits behind,

for example: 'Your branch is behind 'origin/gimp-2-8' by 2 commits, and can be fast-forwarded.'

Cause: On git pull Git didn't update the HEAD on your local branch for whatever reason.

Solution: Try git pull origin to update your local branch.

Translating

Problem: I'm translating on the current production branch of GIMP (2-8 etc.) and on master. I'd like to cherry-pick my changes from the production branch to the master branch. But I get lots of merge conflicts and changes I never introduced.

Cause: Cherry-picking translations from the production branch into the master branch doesn't work.

Solution: Commit your translation updates directly into the master branch or try to merge your translation branch into the master branch.


Templates

Template for investigated solutions

Problem:

Cause:

Solution:

Template for workarounds

Problem:

Workaround:

Anyway, this is just a workaround. If you know the cause and a proper solution, feel free to edit this posting.