Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 459820 - app-emulation/emul-linux-x86-baselibs-20121202 - libtiff appears to be broken because it needs different headers per arch
Summary: app-emulation/emul-linux-x86-baselibs-20121202 - libtiff appears to be broken...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Gentoo Graphics Project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: gx86-multilib
  Show dependency tree
 
Reported: 2013-03-01 02:37 UTC by Austin English (RETIRED)
Modified: 2013-08-10 17:52 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
tiff-4.0.3-r2 converted for the ABI_X86="32" (tiff-4.0.3-r2.ebuild,1.51 KB, text/plain)
2013-03-13 18:56 UTC, Samuli Suominen (RETIRED)
Details
Proper, working patch for 4.0.3-r1 (tiff-4.0.3-r1.ebuild.patch,1.94 KB, patch)
2013-04-01 10:55 UTC, Michał Górny
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Austin English (RETIRED) gentoo-dev 2013-03-01 02:37:24 UTC
Noticed while running wine's conformance tests:
austin@aw25 ~/wine-git/dlls/windowscodecs/tests $ make tiffformat.ok 
../../../tools/runtest -q -P wine -M windowscodecs.dll -T ../../.. -p windowscodecs_test.exe.so tiffformat.c && touch tiffformat.ok
fixme:iphlpapi:NotifyAddrChange (Handle 0x123e8d0, overlapped 0x123e8dc): stub
wine: configuration in '/home/austin/.wine' has been updated.
TIFFFetchDirectory: <IStream object>: Seek error accessing TIFF directory.
TIFFReadDirectory: Failed to read directory at offset 8.
tiffformat.c:142: Test failed: CreateDecoderFromStream error 0x88982f50
..

if I instead build 64-bit wine, the test passes as expected (note that you must run the tests slightly differently):
austin@aw25 ~/wine-64/dlls/windowscodecs/tests $ ~/wine-64/loader/wine64 windowscodecs_test.exe.so converter
fixme:wincodecs:WICConvertBitmapSource cannot convert {6fddc324-4e03-4bfe-b185-3d77768dc90f} to {f0e749ca-edef-4589-a73a-ee0e626a2a2b}
converter: 294 tests executed (0 marked as todo, 0 failures), 0 skipped.


Note that the test passes for me on 64-bit fedora and others in a 64-bit OS with wine in 32-bit mode.

Reproducible: Always

Steps to Reproduce:
git clone git://source.winehq.org/git/wine.git
cd wine
./configure
make
cd dlls/windowscodecs/tests
make tiffformat.ok
Actual Results:  
Test to pass

Expected Results:  
Test crashes

gdiplus:image and windowscodecs:converter have similar issues.
Comment 1 Pacho Ramos gentoo-dev 2013-03-04 19:26:35 UTC
Please retry with 20130224 set
Comment 2 Austin English (RETIRED) gentoo-dev 2013-03-04 20:58:16 UTC
(In reply to comment #1)
> Please retry with 20130224 set

Still present:
austin@aw25 ~/wine-git/dlls/windowscodecs/tests $ make tiffformat.ok 
../../../tools/runtest -q -P wine -M windowscodecs.dll -T ../../.. -p windowscodecs_test.exe.so tiffformat.c && touch tiffformat.ok
TIFFFetchDirectory: <IStream object>: Seek error accessing TIFF directory.
TIFFReadDirectory: Failed to read directory at offset 8.
tiffformat.c:142: Test failed: CreateDecoderFromStream error 0x88982f50
wine: Unhandled page fault on read access to 0x00000000 at address 0x7ed517c5 (thread 0009), starting debugger...


austin@aw25 ~/wine-git/dlls/windowscodecs/tests $ equery list emul-linux-x86-baselibs
 * Searching for emul-linux-x86-baselibs ...
[IP-] [  ] app-emulation/emul-linux-x86-baselibs-20130224:0
Comment 3 Pacho Ramos gentoo-dev 2013-03-04 21:17:58 UTC
I don't see anything special in emul chroot, it provides:
media-libs/tiff-4.0.2-r1  USE="cxx jpeg zlib -jbig -lzma -static-libs"

Will CC tiff maintainers and wine people (last for confirming this is a proper way to check for tiff integrity)
Comment 4 Austin English (RETIRED) gentoo-dev 2013-03-13 18:20:31 UTC
Some debugging in #winehackers points to a header mismatch:
<vpovirk> austin987: I think it's a header/lib mismatch
<vpovirk> austin987: if I find and replace "toff_t" with "LONGLONG" in tiffformat.c, it works
<vpovirk> so we're getting the wrong definition of that somehow
<vpovirk> typedef uint64 toff_t;          /* file offset */
<vpovirk> not sure how we could be screwing that up..
...
<vpovirk> typedef unsigned long uint64;
<vpovirk> austin987: I think it means you're using the 64-bit tiffconf.h in  your 32-bit build
<austin987> vpovirk, that's certainly possible
<austin987> let me try your fix, sec
<austin987> tiffformat.c: In function ‘tiff_open_stream’:
<austin987> tiffformat.c:210:9: warning: passing argument 6 of ‘pTIFFClientOpen’ from incompatible pointer type
<austin987> tiffformat.c:210:9: note: expected ‘TIFFSeekProc’ but argument is of type ‘LONGLONG (*)(void *, LONGLONG,  int)’
<austin987> vpovirk, tests pass, but then I get those warnings ^
<vpovirk> well, yeah, because it doesn't match your definition of toff_t
<vpovirk> which is incorrectly 32-bit
<austin987> ah, right
Comment 5 Samuli Suominen (RETIRED) gentoo-dev 2013-03-13 18:55:03 UTC
There is...

--- tiff-4.0.3-amd64/libtiff/tif_config.h	2013-03-13 20:50:48.581435215 +0200
+++ tiff-4.0.3-x86/libtiff/tif_config.h	2013-03-13 20:50:42.854435674 +0200
@@ -200,7 +200,7 @@
 #define LT_OBJDIR ".libs/"
 
 /* Support LZMA2 compression */
-#define LZMA_SUPPORT 1
+/* #undef LZMA_SUPPORT */
 
 /* Support LZW algorithm */
 #define LZW_SUPPORT 1
@@ -252,7 +252,7 @@
 #define SIZEOF_SIGNED_INT 4
 
 /* The size of `signed long', as computed by sizeof. */
-#define SIZEOF_SIGNED_LONG 8
+#define SIZEOF_SIGNED_LONG 4
 
 /* The size of `signed long long', as computed by sizeof. */
 #define SIZEOF_SIGNED_LONG_LONG 8
@@ -261,13 +261,13 @@
 #define SIZEOF_SIGNED_SHORT 2
 
 /* The size of `unsigned char *', as computed by sizeof. */
-#define SIZEOF_UNSIGNED_CHAR_P 8
+#define SIZEOF_UNSIGNED_CHAR_P 4
 
 /* The size of `unsigned int', as computed by sizeof. */
 #define SIZEOF_UNSIGNED_INT 4
 
 /* The size of `unsigned long', as computed by sizeof. */
-#define SIZEOF_UNSIGNED_LONG 8
+#define SIZEOF_UNSIGNED_LONG 4
 
 /* The size of `unsigned long long', as computed by sizeof. */
 #define SIZEOF_UNSIGNED_LONG_LONG 8
@@ -301,10 +301,10 @@
 #define TIFF_INT32_T signed int
 
 /* Signed 64-bit type formatter */
-#define TIFF_INT64_FORMAT "%ld"
+#define TIFF_INT64_FORMAT "%lld"
 
 /* Signed 64-bit type */
-#define TIFF_INT64_T signed long
+#define TIFF_INT64_T signed long long
 
 /* Signed 8-bit type */
 #define TIFF_INT8_T signed char
@@ -331,10 +331,10 @@
 #define TIFF_UINT32_T unsigned int
 
 /* Unsigned 64-bit type formatter */
-#define TIFF_UINT64_FORMAT "%lu"
+#define TIFF_UINT64_FORMAT "%llu"
 
 /* Unsigned 64-bit type */
-#define TIFF_UINT64_T unsigned long
+#define TIFF_UINT64_T unsigned long long
 
 /* Unsigned 8-bit type */
 #define TIFF_UINT8_T unsigned char
@@ -375,7 +375,7 @@
 #endif
 
 /* Number of bits in a file offset, on hosts where this is settable. */
-/* #undef _FILE_OFFSET_BITS */
+#define _FILE_OFFSET_BITS 64
 
 /* Define for large files, on AIX-style hosts. */
 /* #undef _LARGE_FILES */
diff -ur tiff-4.0.3-amd64/libtiff/tiffconf.h tiff-4.0.3-x86/libtiff/tiffconf.h
--- tiff-4.0.3-amd64/libtiff/tiffconf.h	2013-03-13 20:50:48.591435214 +0200
+++ tiff-4.0.3-x86/libtiff/tiffconf.h	2013-03-13 20:50:42.864435673 +0200
@@ -15,7 +15,7 @@
 #define TIFF_INT32_T signed int
 
 /* Signed 64-bit type */
-#define TIFF_INT64_T signed long
+#define TIFF_INT64_T signed long long
 
 /* Signed 8-bit type */
 #define TIFF_INT8_T signed char
@@ -27,7 +27,7 @@
 #define TIFF_UINT32_T unsigned int
 
 /* Unsigned 64-bit type */
-#define TIFF_UINT64_T unsigned long
+#define TIFF_UINT64_T unsigned long long
 
 /* Unsigned 8-bit type */
 #define TIFF_UINT8_T unsigned char

and maybe more, it's either 32bit or 64bit headers, I'm not sure what to do
Comment 6 Samuli Suominen (RETIRED) gentoo-dev 2013-03-13 18:56:54 UTC
Created attachment 341938 [details]
tiff-4.0.3-r2 converted for the ABI_X86="32"

Here is the ebuild I wrote, but it fails with the headers checksum since they vary based on bits (and the ebuild correctly aborts)
Comment 7 Pacho Ramos gentoo-dev 2013-03-13 21:58:01 UTC
Will CC mgorny to see this new example of a package needing different headers and try to know how to handle it :/
Comment 8 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-03-14 08:09:14 UTC
(In reply to comment #7)
> Will CC mgorny to see this new example of a package needing different
> headers and try to know how to handle it :/

You know my preferred solution to this and you can guess that cmake can't handle it :).

So we have the following options:

1) wrap the headers like Tommy suggests and flameeyes strongly dislikes,

2) invent a new ABI-specific header location -- we can hack it into ebuilds via multilib_toolchain_setup but that leaves non-multilib packages,

3) install the headers into includedir+libdir and rely on pkg-config,

4) hack the headers not to be ABI-specific.

where options 2) + 3) would involve installing a set of headers for the default ABI into includedir to have all the 'regular' packages working, and other ones elsewhere so that multilib packages would have it overriden via pkg-config.

But I think that would be very fragile (esp. if something appended -I/usr/include). That probably leaves us with 1) or 4), with 4) being the hacky but stylish way, and 1) being the quick hack that should work.

Another thing is that someone should report that upstream and see what they think.
Comment 9 Pacho Ramos gentoo-dev 2013-03-14 19:40:31 UTC
Will wait for graphics team to decide on this specific tiff issue, but probably wrapping way will be needed sooner or later
Comment 10 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-04-01 09:30:56 UTC
(In reply to comment #9)
> Will wait for graphics team to decide on this specific tiff issue, but
> probably wrapping way will be needed sooner or later

autotools-multilib can handle header wrapping now.

  MULTILIB_WRAPPED_HEADERS=( /usr/include/... )

And please test it :).
Comment 11 Pacho Ramos gentoo-dev 2013-04-01 09:53:12 UTC
Then, probably the way to solve this is to migrate to new multilib eclasses
Comment 12 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-04-01 10:55:51 UTC
Created attachment 343918 [details, diff]
Proper, working patch for 4.0.3-r1

Of course, it needs bumped emul-linux-x86-baselibs due to circular dep.
Comment 13 Richard Yao (RETIRED) gentoo-dev 2013-06-18 19:13:53 UTC
One of the people in #winehq pinged me about this, so I will obligate. Has anyone thought of modifying libtiff to use stdint.h and sending the patch upstream? That could fix the bitness issues.
Comment 14 Austin English (RETIRED) gentoo-dev 2013-08-01 19:55:36 UTC
Note that wine now works around this (it will be in 1.7.0+):
http://source.winehq.org/git/wine.git/commitdiff/3894493a76cb766c4322f09a1d12b9723d3d3759

but the bug is still present in other applications / libtiff.
Comment 15 Alexis Ballier gentoo-dev 2013-08-10 17:52:01 UTC
migrated tiff4 is now in tree