Source: erlang-cherly Version: 0.12.8+dfsg-7 Severity: important Tags: patch upstream User: debian-sparc@lists.debian.org Usertags: sparc64 X-Debbugs-Cc: debian-sparc@lists.debian.org
Hi, Currently erlang-cherly FTBFS on sparc64 due to SIGBUSes in the test suite. On investigating, I found this was because its uintptr type was being typedef'd as 32-bit, as only amd64 and ia64 were being checked for with the preprocessor. The attached patch switches to _LP64 as that is the least invasive change, but perhaps it should be using the standard uintptr_t instead. During this I also found that the indirectval was not being set to 0 and instead being left uninitialised (for example, I saw it have the value 'H'); I believe this could cause memory corruption if valsize_in_hash is less than sizeof(void *), since indirectval could be spuriously true and treating the inline value as a pointer would overflow the allocated space. It also of course wastes time and space over storing the value inline. Regards, James
diff -Nru erlang-cherly-0.12.8+dfsg/debian/patches/correct-uintptr-type.patch erlang-cherly-0.12.8+dfsg/debian/patches/correct-uintptr-type.patch --- erlang-cherly-0.12.8+dfsg/debian/patches/correct-uintptr-type.patch 1970-01-01 01:00:00.000000000 +0100 +++ erlang-cherly-0.12.8+dfsg/debian/patches/correct-uintptr-type.patch 2017-08-17 20:18:41.000000000 +0100 @@ -0,0 +1,11 @@ +--- a/c_src/runtime.h ++++ b/c_src/runtime.h +@@ -19,7 +19,7 @@ typedef unsigned long long int uint64; + typedef float float32; + typedef double float64; + +-#if defined(__ia64) || defined(__x86_64) || defined(__amd64) ++#if defined(_LP64) + typedef uint64 uintptr; + typedef int64 intptr; + #else diff -Nru erlang-cherly-0.12.8+dfsg/debian/patches/initialize-indirectval.patch erlang-cherly-0.12.8+dfsg/debian/patches/initialize-indirectval.patch --- erlang-cherly-0.12.8+dfsg/debian/patches/initialize-indirectval.patch 1970-01-01 01:00:00.000000000 +0100 +++ erlang-cherly-0.12.8+dfsg/debian/patches/initialize-indirectval.patch 2017-08-17 20:20:16.000000000 +0100 @@ -0,0 +1,12 @@ +--- a/c_src/hashmap.c ++++ b/c_src/hashmap.c +@@ -711,7 +711,8 @@ runtime_makemap_c(MapType *typ, int64 hi + if (val->size > MaxValsize) { + h->indirectval = 1; + valsize_in_hash = sizeof(void*); +- } ++ } else ++ h->indirectval = 0; + + // Align value inside data so that mark-sweep gc can find it. + h->valoff = key->size; diff -Nru erlang-cherly-0.12.8+dfsg/debian/patches/series erlang-cherly-0.12.8+dfsg/debian/patches/series --- erlang-cherly-0.12.8+dfsg/debian/patches/series 2016-12-20 13:10:20.000000000 +0000 +++ erlang-cherly-0.12.8+dfsg/debian/patches/series 2017-08-17 20:23:15.000000000 +0100 @@ -1,2 +1,4 @@ add_support_r17_and_r18 using-crypto_strong_rand_bytes +initialize-indirectval.patch +correct-uintptr-type.patch