On 13 February 2014 00:01,  <marti.ma...@littlecms.com> wrote:
> Please feel free to download and check the CMM in your application

I've run the colord test suite against the new lcms2. There are a lot
of compiler warnings now like this:

In file included from cd-create-profile.c:27:0:
/usr/include/lcms2.h:1568:14: note: expected ‘cmsContext’ but argument
is of type ‘struct CdIcc *’
 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreate_sRGBProfileTHR(cmsContext
ContextID);

This is the backtrace, which isn't always the same:

/colord/icc{clear}:
Program received signal SIGSEGV, Segmentation fault.
__GI___libc_free (mem=0x140) at malloc.c:2892
2892  if (chunk_is_mmapped(p))                       /* release
mmapped memory. */
Missing separate debuginfos, use: debuginfo-install
gvfs-1.18.3-2.fc20.x86_64 lcms2-2.6-999.60.20140213git.fc20.x86_64
libbluray-0.5.0-2.fc20.x86_64 libffi-3.0.13-5.fc20.x86_64
libgcc-4.8.2-7.fc20.x86_64 libselinux-2.2.1-6.fc20.x86_64
pcre-8.33-4.fc20.x86_64 systemd-libs-208-9.fc20.x86_64
xz-libs-5.1.2-6alpha.fc20.x86_64
(gdb) bt
#0  __GI___libc_free (mem=0x30) at malloc.c:2892
#1  0x00007ffff724473b in cmsMLUfree (mlu=0x65e3a0) at cmsnamed.c:286
#2  0x00007ffff7231e43 in cmsCloseProfile (hProfile=0x62c810) at cmsio0.c:1393
#3  0x00007ffff7bc052c in cd_icc_finalize (object=0x63b380) at cd-icc.c:4404
#4  0x00007ffff6a76fcb in g_object_unref (_object=0x63b380) at gobject.c:3197
#5  0x000000000040cf22 in colord_icc_clear_func () at cd-test-private.c:1168
#6  0x00007ffff659f5e1 in test_case_run (tc=0x6242a0) at gtestutils.c:2067
#11 0x0000000000405acc in main (argc=1, argv=0x7fffffffdd88) at
cd-test-private.c:2091

This test case is creating model mluc tag in a simple V4 profile.

I'm slightly confused about the new context work after reading the
docs. This program fails:

//gcc -o test test.c `pkg-config --cflags --libs lcms2` && ./test

#include <lcms2.h>
#include <stdlib.h>

int
main(int argc, char *argv[])
{
cmsHPROFILE p;
void *myuserdata = 0x12345;
p = cmsCreate_sRGBProfileTHR (myuserdata);
cmsCloseProfile(p);
return 0;
}

i.e. any program that's been using the _THR() functions with their own
static userdata rather than using the new cmsCreateContext() is going
to explode with:

Program received signal SIGSEGV, Segmentation fault.
_cmsGetContext (ContextID=0x12345) at cmsplugin.c:673
673    if (ctx ->Magic != cmsContextMagicNumber)

i.e. you're trying to dereference ctx when it's not a memory location.
The same thing happens when trying to read Magic from a small struct
(which all of the GObject programs typically are):

typedef struct {
int test;
} teststruct;

int
main(int argc, char *argv[])
{
cmsHPROFILE p;
teststruct ctx;
p = cmsCreate_sRGBProfileTHR (&ctx);
cmsCloseProfile(p);
return 0;
}

gives 43 *different* versions of this in valgrind:

==14270== Conditional jump or move depends on uninitialised value(s)
==14270==    at 0x4E4F02F: _cmsGetContext (cmsplugin.c:673)
==14270==    by 0x4E4F0B0: _cmsContextGetClientChunk (cmsplugin.c:694)
==14270==    by 0x4E40AEA: _cmsFree (cmserr.c:286)
==14270==    by 0x4E48EAB: cmsCloseProfile (cmsio0.c:1406)
==14270==    by 0x40072A: main (in /home/hughsie/Code/colord/lib/colord/test)

I'm _really_not_happy_ with the guessing in _cmsGetContext as it's
going to blow-up in hard-to-detect ways. CMS_CONTEXT_IN_LEGACY_MODE
doesn't work in this case as it's only affecting the compile warning,
rather than the underlying ABI issue.

I guess the new functioanlity could be worked around without the
soname bump if you could compile the *library* with
CMS_CONTEXT_IN_LEGACY_MODE (rather than the user program) although I
was slightly surprised at the need to define a new #ifdef to have the
old behaviour. In Fedora I guess we'd have to just do
-DCMS_CONTEXT_IN_LEGACY_MODE=1 when compiling lcms2, and patch
'#define CMS_CONTEXT_IN_LEGACY_MODE' into the top of lcms2.h which
probably makes the ghostscript guys sad. The alternative means we
anything using _THR() crashes and when valgrinding we get thousands of
invalid reads from deep in the lcms2 library.

What might be a better thing to do is have a global function
cmsSetContextMode() which enables the new functionality at runtime
*if* the project has ported to the new cmsCreateContext() code. The
alternative is you have to bump the soname. Sorry to be grumpy.

Richard.

------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
Lcms-user mailing list
Lcms-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lcms-user

Reply via email to