Bug 702349 - ImageMagick coredumps in libgs while convert pdf to png if IM compiled with LCMS2 and GSLIB support
Summary: ImageMagick coredumps in libgs while convert pdf to png if IM compiled with L...
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Color Management (show other bugs)
Version: 9.52
Hardware: PC FreeBSD
: P4 normal
Assignee: Chris Liddell (chrisl)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-22 17:33 UTC by VVD
Modified: 2020-04-27 21:07 UTC (History)
2 users (show)

See Also:
Customer:
Word Size: 64


Attachments
visibility of lcms2mt (3.33 KB, patch)
2020-04-27 16:34 UTC, VVD
Details | Diff
Visibility of lcms2mt. (3.33 KB, patch)
2020-04-27 16:38 UTC, VVD
Details | Diff
Visibility of lcms2mt. (925 bytes, patch)
2020-04-27 17:06 UTC, VVD
Details | Diff
Doesn't work. (3.48 KB, patch)
2020-04-27 17:20 UTC, VVD
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description VVD 2020-04-22 17:33:45 UTC
ImageMagick (6 and 7) compiled with LCMS2 and with GSLIB coredumps during converting PDF to PNG.
ImageMagick compiled without LCMS2 and with GSLIB work fine.
ImageMagick compiled with LCMS2 and without GSLIB work fine.
gs binary from ghostscript 9.52 convert PDF to PNG without errors too.

Probably this is a conflict between installed lcms2 amd embedded lcms2mt: ImageMagick linked with liblcms2 and with libgs, but libgs have embedded binary incompatible lcms2 (functions with same names).

All information, include gdb's backtraces, are here: https://github.com/ImageMagick/ImageMagick/discussions/1908
More related bug reports:
https://github.com/mm2/Little-CMS/issues/207
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=245782

FreeBSD 12.1 amd64.
Comment 1 VVD 2020-04-26 23:03:13 UTC
What other information I have to show?
Comment 2 Robin Watts 2020-04-26 23:31:43 UTC
Yes, as you say, that's quite possibly a conflict between lcms2mt and lcms2.

BUT... it's not a gs bug. It's an Imagemagick one, you should report it to them. It's a problem with their integration.

Or at least, it's down to the person that tried to link libraries built in conflicting ways.
Comment 3 VVD 2020-04-26 23:49:56 UTC
> It's an Imagemagick one, you should report it to them.
Already did. Read, plz, links above.

> Or at least, it's down to the person that tried to link libraries built in conflicting ways.
What is the correct way?
ImageMagick using lcms2 and libgs.
Comment 4 Robin Watts 2020-04-27 09:41:20 UTC
Apologies, I handled this badly.

My point was intended to be that you should report the issue to the maintainers of IM, and they should contact us to work together to solve the problem.

BUT, one of my colleagues may have a workaround.
Comment 5 Chris Liddell (chrisl) 2020-04-27 11:52:49 UTC
*if* the segfault is being caused by a symbol clash between lcms2mt (in gs) and lcms2 (in ImageMagick), then I *think* this should resolve it:

http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=f210e4c009f7


I'm closing this as resolved/fixed. If that turns out not to be the problem (or the above solution doesn't work), could you re-open and point the Imagemagick devs at this bug, or #ghostscript (on freenode) or the gs-devel mailing list (links on ghostcript.com), we can work with them to find a solution? Thanks.
Comment 6 VVD 2020-04-27 16:34:02 UTC
Created attachment 19181 [details]
visibility of lcms2mt

Thanks.

This patch work for me.
Look at configure changes - without it I got error.
Comment 7 VVD 2020-04-27 16:38:07 UTC
Created attachment 19182 [details]
Visibility of lcms2mt.

This one is correct.
Comment 8 VVD 2020-04-27 16:41:14 UTC
Oh, wait.
Comment 9 VVD 2020-04-27 17:06:35 UTC
Created attachment 19183 [details]
Visibility of lcms2mt.

This one work.
2nd doesn't work.
Comment 10 VVD 2020-04-27 17:20:35 UTC
Created attachment 19184 [details]
Doesn't work.

This patch doesn't work with hard coded CFLAGS_VISIBILITY="-fvisibility=hidden" in configure.ac.
But if it hard coded in Makefile.in - work fine.
Comment 11 Chris Liddell (chrisl) 2020-04-27 17:31:58 UTC
(In reply to VVD from comment #10)
> Created attachment 19184 [details]
> Doesn't work.
> 
> This patch doesn't work with hard coded
> CFLAGS_VISIBILITY="-fvisibility=hidden" in configure.ac.
> But if it hard coded in Makefile.in - work fine.

Well, hard coding in Makefile.in is unacceptable - we have to support more compilers than just gcc and clang.

I can't see any reason why the tests in configure.ac would not work (they certainly do on Linux), and I don't have a FreeBSD install to test on.
Comment 12 VVD 2020-04-27 17:56:02 UTC
(In reply to Chris Liddell (chrisl) from comment #11)
> Well, hard coding in Makefile.in is unacceptable - we have to support more
> compilers than just gcc and clang.
Agree, ofc you are right.

> I can't see any reason why the tests in configure.ac would not work (they
> certainly do on Linux), and I don't have a FreeBSD install to test on.
He is not transferred from configure.ac to this Makefile.in.

Without this one:
--- configure.orig
+++ configure
@@ -868,6 +868,7 @@
 ECHO_N
 ECHO_C
 DEFS
+CFLAGS_VISIBILITY
 mandir
 localedir
 libdir

I got error:
cc: error: no such file or directory: '@CFLAGS_VISIBILITY@'
gmake[4]: *** [base/lcms2mt.mak:101: soobj/cmscam02.o] Error 1
Comment 13 Chris Liddell (chrisl) 2020-04-27 17:58:43 UTC
You need to run autogen.sh to regenerate configure from configure.ac.
Comment 14 VVD 2020-04-27 21:07:32 UTC
(In reply to Chris Liddell (chrisl) from comment #13)
> You need to run autogen.sh to regenerate configure from configure.ac.
FreeBSD port print/ghostscript9-agpl-base doesn't use autogen.sh during build process. It patch configure and run it:
https://svnweb.freebsd.org/ports/head/print/ghostscript9-agpl-base/files/

I made patch for port print/ghostscript9-agpl-base: https://bugs.freebsd.org/bugzilla/attachment.cgi?id=213868&action=diff

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=245782

Thanks a lot for fix it!