seikichi / tiff.js

tiff.js is a port of LibTIFF by compiling the LibTIFF C code with Emscripten.
Other
383 stars 97 forks source link

Run Time Fail: assert(sizeof(uint64)==8); #6

Open jlpoolen opened 9 years ago

jlpoolen commented 9 years ago

I tried to compile my own version after setting up emscripten on my Gentoo Linux (64) machine. There were warnings issued during the compile documented in another ticket filed shortly before this one. Otherwise, the file built without incident except that the last step of using clojure failed as I do not have closure installed. My understanding is clojure simply compresses and obfuscates the JavaScript, there is no material change. Basically I modified the this project's file basic.html to reference my JavaScript (not compressed).

When I try to load a sample page I receive in my Firefox browser with Firebug Tools activated:

uncaught exception: Assertion failed: sizeof(uint64)==8, at: tif_open.c,99,
TIFFClientOpen at jsStackTrace@file:///D:/work/EP/TIFF/tiff_js/tiff_jlpoole.js:1062:7 
stackTrace@file:///D:/work/EP/TIFF/tiff_js/tiff_jlpoole.js:1079:3 
___assert_fail@file:///D:/work/EP/TIFF/tiff_js/tiff_jlpoole.js:4145:146 
_TIFFClientOpen@file:///D:/work/EP/TIFF/tiff_js/tiff_jlpoole.js:31018:2 
_TIFFOpen@file:///D:/work/EP/TIFF/tiff_js/tiff_jlpoole.js:33658:3 
loadModule/asm._TIFFOpen@file:///D:/work/EP/TIFF/tiff_js/tiff_jlpoole.js:68363:3 
ccallFunc@file:///D:/work/EP/TIFF/tiff_js/tiff_jlpoole.js:574:9 
Tiff@file:///D:/work/EP/TIFF/tiff_js/tiff_jlpoole.js:70517:104 
loadImage/xhr.onload@file:///D:/work/EP/TIFF/tiff_js/basic_jlpoole.html:32:25

tiff_open.c around line 99 has:

/* The following are configuration checks. They should be redundant, but should not
     * compile to any actual code in an optimised release build anyway. If any of them
     * fail, (makefile-based or other) configuration is not correct */
    assert(sizeof(uint8)==1);
    assert(sizeof(int8)==1);
    assert(sizeof(uint16)==2);
    assert(sizeof(int16)==2);
    assert(sizeof(uint32)==4);
    assert(sizeof(int32)==4);
    assert(sizeof(uint64)==8);
    assert(sizeof(int64)==8);

The system I compiled on is a 64 bit system:

jlpoole@themis ~/work/tiff/tiff.js/trunk/tiff-4.0.3 $ uname -a
Linux themis 3.12.13-gentoo #1 SMP Thu Apr 10 15:16:31 PDT 2014 x86_64 Intel(R) Core(TM) i5 CPU M 460 @ 2.53GHz GenuineIntel GNU/Linux
jlpoole@themis ~/work/tiff/tiff.js/trunk/tiff-4.0.3 $
marknuzz commented 8 years ago

This is happening to me also.

In tiffconf.h:

define TIFF_UINT64_T unsigned long long

In tiff.h: typedef TIFF_UINT64_T uint64;

tiffconf.h is implementation specific. My guess is that the build script doesn't incorporate this file for whatever reason.

marknuzz commented 8 years ago

When building with build.sh I am seeing:

define TIFF_UINT64_T unsigned long

This is the default on a 64 bit architecture, but on a 32 bit architecture, long is 32 bits. Somewhere in the process, the code is being interpreted as 32 bit even though it is compiled for a 64 bit architecture.

I'm changing the ./configure line to include the args CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=m32

This will keep things in 32 bit mode across the board and hopefully generate correct configuration.

marknuzz commented 8 years ago

Confirmed the above solution works