[med-svn] [Git][med-team/staden-io-lib][master] 4 commits: Apply three patches from upstream to fix bugs on several architectures

Andreas Tille gitlab at salsa.debian.org
Fri Dec 7 12:07:19 GMT 2018


Andreas Tille pushed to branch master at Debian Med / staden-io-lib


Commits:
9ceda5d5 by Andreas Tille at 2018-12-07T06:56:18Z
Apply three patches from upstream to fix bugs on several architectures

- - - - -
1da454e9 by Andreas Tille at 2018-12-07T07:04:03Z
Upload to unstable

- - - - -
d4982818 by Andreas Tille at 2018-12-07T11:53:07Z
Fix hash table HASH_INT_KEYS on 32-bit platforms

- - - - -
ac9ba754 by Andreas Tille at 2018-12-07T11:55:19Z
Do not attempt to run test suite for architecture independant build.

- - - - -


7 changed files:

- debian/changelog
- + debian/patches/1b28b6a.patch
- + debian/patches/242cd6b.patch
- + debian/patches/37b33d3.patch
- + debian/patches/d4591b5.patch
- debian/patches/series
- debian/rules


Changes:

=====================================
debian/changelog
=====================================
@@ -1,3 +1,20 @@
+staden-io-lib (1.14.11-5) UNRELEASED; urgency=medium
+
+  * Fix hash table HASH_INT_KEYS on 32-bit platforms (thanks to
+    upstream Rob Davies)
+  * Do not attempt to run test suite for architecture independant
+    build.
+
+ -- Andreas Tille <tille at debian.org>  Fri, 07 Dec 2018 12:52:29 +0100
+
+staden-io-lib (1.14.11-4) unstable; urgency=medium
+
+  * Apply three patches from upstream to fix bugs on several
+    architectures (thanks a lot for the support by James Bonfield)
+    Closes: #915450, #915459, #915460
+
+ -- Andreas Tille <tille at debian.org>  Fri, 07 Dec 2018 07:56:28 +0100
+
 staden-io-lib (1.14.11-3) unstable; urgency=medium
 
   * Remove bashism in test script


=====================================
debian/patches/1b28b6a.patch
=====================================
@@ -0,0 +1,28 @@
+From: James Bonfield <jkb at sanger.ac.uk>
+Date: Thu, 6 Dec 2018 12:23:53 +0000
+Origin: https://github.com/jkbonfield/io_lib/commit/1b28b6a.patch
+Bug-Debian: https://bugs.debian.org/915460
+Subject: [PATCH] Fix rANS codec on x32 architecture.
+
+This is 32-bit usage of a 64-bit processor.  See
+https://wiki.debian.org/X32Port
+
+Should fix the bug found here:
+https://buildd.debian.org/status/fetch.php?pkg=staden-io-lib&arch=x32&ver=1.14.11-3&stamp=1543952038&raw=0
+---
+ io_lib/rANS_static.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/io_lib/rANS_static.c b/io_lib/rANS_static.c
+index 4cd6264..e2f64a2 100644
+--- a/io_lib/rANS_static.c
++++ b/io_lib/rANS_static.c
+@@ -339,7 +339,7 @@ static inline void RansDecAdvanceSymbolStep(RansState* r, RansDecSymbol const* s
+ }
+ 
+ // Renormalize.
+-#ifdef __x86_64
++#if defined(__x86_64) && !defined(__ILP32__)
+ /*
+  * Assembly variants of the RansDecRenorm code.
+  * These are based on joint ideas from Rob Davies and from looking at


=====================================
debian/patches/242cd6b.patch
=====================================
@@ -0,0 +1,64 @@
+From: Rob Davies <rmd+git at sanger.ac.uk>
+Date: Fri, 7 Dec 2018 11:11:12 +0000
+Origin: https://github.com/jkbonfield/io_lib/commit/242cd6b
+Bug-Debian: https://bugs.debian.org/915460
+Subject: [PATCH] Fix hash table HASH_INT_KEYS on 32-bit platforms
+
+The hash table has the option to declare the key pointer is the key
+itself rather than the memory it points to.  It assumed however that
+the key was 8 bytes long, rather than sizeof(char *).
+
+Fixes Debian Bug#915460
+---
+ io_lib/hash_table.c | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/io_lib/hash_table.c b/io_lib/hash_table.c
+index 6c37ff8..238cafa 100644
+--- a/io_lib/hash_table.c
++++ b/io_lib/hash_table.c
+@@ -478,7 +478,7 @@ int HashTableResize(HashTable *h, int newsize) {
+ 	for (hi = h->bucket[i]; hi; hi = next) {
+ 	    uint64_t hv = h2->options & HASH_INT_KEYS
+ 		? hash64(h2->options & HASH_FUNC_MASK,
+-			 (uint8_t *)&hi->key, hi->key_len) & h2->mask
++			 (uint8_t *)&hi->key, sizeof(hi->key)) & h2->mask
+ 		: hash64(h2->options & HASH_FUNC_MASK,
+ 			 (uint8_t *)hi->key, hi->key_len) & h2->mask;
+ 	    next = hi->next;
+@@ -535,7 +535,7 @@ HashItem *HashTableAdd(HashTable *h, char *key, int key_len, HashData data,
+ 	key_len = strlen(key);
+ 
+     hv = h->options & HASH_INT_KEYS
+-	? hash64(h->options & HASH_FUNC_MASK, (uint8_t *)&key, key_len) & h->mask
++	? hash64(h->options & HASH_FUNC_MASK, (uint8_t *)&key, sizeof(key)) & h->mask
+ 	: hash64(h->options & HASH_FUNC_MASK, (uint8_t *)key, key_len) & h->mask;
+ 
+     /* Already exists? */
+@@ -603,7 +603,7 @@ int HashTableDel(HashTable *h, HashItem *hi, int deallocate_data) {
+ 
+     hv = h->options & HASH_INT_KEYS
+ 	? hash64(h->options & HASH_FUNC_MASK,
+-		 (uint8_t *)&hi->key, hi->key_len) & h->mask
++		 (uint8_t *)&hi->key, sizeof(hi->key)) & h->mask
+ 	: hash64(h->options & HASH_FUNC_MASK,
+ 		 (uint8_t *)hi->key, hi->key_len) & h->mask;
+ 
+@@ -651,7 +651,7 @@ int HashTableRemove(HashTable *h, char *key, int key_len,
+ 	key_len = strlen(key);
+ 
+     hv = h->options & HASH_INT_KEYS
+-	? hash64(h->options & HASH_FUNC_MASK, (uint8_t *)&key, key_len) & h->mask
++	? hash64(h->options & HASH_FUNC_MASK, (uint8_t *)&key, sizeof(key)) & h->mask
+ 	: hash64(h->options & HASH_FUNC_MASK, (uint8_t *)key, key_len) & h->mask;
+ 
+     last = NULL;
+@@ -702,7 +702,7 @@ HashItem *HashTableSearch(HashTable *h, char *key, int key_len) {
+ 	key_len = strlen(key);
+ 
+     if (h->options & HASH_INT_KEYS) {
+-	hv = hash64(h->options & HASH_FUNC_MASK, (uint8_t *)&key, key_len)& h->mask;
++	hv = hash64(h->options & HASH_FUNC_MASK, (uint8_t *)&key, sizeof(key))& h->mask;
+ 
+ 	for (hi = h->bucket[hv]; hi; hi = hi->next) {
+ 	    if ((int)(size_t)key == (int)(size_t)hi->key)


=====================================
debian/patches/37b33d3.patch
=====================================
@@ -0,0 +1,57 @@
+From: James Bonfield <jkb at sanger.ac.uk>
+Date: Thu, 6 Dec 2018 12:00:39 +0000
+Origin: https://github.com/jkbonfield/io_lib/commit/37b33d3.patch
+Bug-Debian: https://bugs.debian.org/915459
+Subject: [PATCH] Bug multi-threaded CRAM decode on some systems.
+
+The bulk_cram_to_bam function allocated a large array for the BAM
+objects, but did not ensure the bam structures are aligned on a word
+boundary.  This gave rise to bus errors.  Fixes debian Bug#915459
+---
+ io_lib/bam.h         | 3 ++-
+ io_lib/cram_decode.c | 9 +++++----
+ 2 files changed, 7 insertions(+), 5 deletions(-)
+
+--- a/io_lib/bam.h
++++ b/io_lib/bam.h
+@@ -271,8 +271,9 @@ static inline void bam_set_bin(bam_seq_t
+ #define bam_qual(b)      (bam_seq(b) + (int)(((b)->len+1)/2))
+ #define bam_aux(b)       (bam_qual(b) + (b)->len)
+ 
+-/* Rounds up to the next multiple of 4 */
++/* Rounds up to the next multiple of 4 or 8 */
+ #define round4(v) (((v-1)&~3)+4)
++#define round8(v) (((v-1)&~7)+8)
+ 
+ /* CIGAR operations, taken from samtools bam.h */
+ #define BAM_CIGAR_SHIFT 4
+--- a/io_lib/cram_decode.c
++++ b/io_lib/cram_decode.c
+@@ -2297,14 +2297,15 @@ static int bulk_cram_to_bam(SAM_hdr *bfd
+ 	int sz = bam_size(bfd, fd, &s->crecs[i]);
+ 	if (i < 10000)
+ 	    sizes[i] = sz;
+-	len += sz;
++	len += round8(sz);
+     }
+ 
+-    s->bl = (bam_seq_t **)malloc(s->hdr->num_records * sizeof(*s->bl) + len);
++    s->bl = (bam_seq_t **)malloc(s->hdr->num_records * sizeof(*s->bl) + len + 8);
+     if (!s->bl)
+ 	return -1;
+ 
+-    char *x = ((char *)s->bl) + s->hdr->num_records * sizeof(*s->bl);
++    // Round up to next multiple of 8, to ensure bam structs are 8-byte aligned.
++    char *x = ((char *)s->bl) + round8(s->hdr->num_records * sizeof(*s->bl));
+     for (i = 0; i < s->hdr->num_records; i++) {
+ 	bam_seq_t *b = (bam_seq_t *)x, *o = b;
+ 	int bsize = i < 10000 ? sizes[i] : bam_size(bfd, fd, &s->crecs[i]);
+@@ -2312,7 +2313,7 @@ static int bulk_cram_to_bam(SAM_hdr *bfd
+ 	r |= (cram_to_bam(fd->header, fd, s, &s->crecs[i], i, &b) < 0);
+ 	// if we allocated enough, the above won't have resized b
+ 	assert(o == b && o->alloc == bsize);
+-	x += bsize;
++	x += round8(bsize);
+ 	s->bl[i] = b;
+     }
+ 


=====================================
debian/patches/d4591b5.patch
=====================================
@@ -0,0 +1,128 @@
+From: James Bonfield <jkb at sanger.ac.uk>
+Date: Wed, 5 Dec 2018 14:51:09 +0000
+Origin: https://github.com/jkbonfield/io_lib/commit/d4591b5.patch
+Bug-Debian: https://bugs.debian.org/915450
+Subject: [PATCH] Big endian fix for BAM reading.
+
+Fixes Debian Bug#915450
+---
+ io_lib/bam.c | 52 +++++++++++++++++++++++++++-------------------------
+ 1 file changed, 27 insertions(+), 25 deletions(-)
+
+diff --git a/io_lib/bam.c b/io_lib/bam.c
+index 55d0919..b259b50 100644
+--- a/io_lib/bam.c
++++ b/io_lib/bam.c
+@@ -716,7 +716,7 @@ void *bgzf_decode_thread(void *arg) {
+ 	uint32_t crc1=libdeflate_crc32(0L, (unsigned char *)j->uncomp, j->uncomp_sz);
+ 	uint32_t crc2;
+ 	memcpy(&crc2, j->comp + j->comp_sz, 4);
+-	crc2 = le_int2(crc2);
++	crc2 = le_int4(crc2);
+ 	if (crc1 != crc2) {
+ 	    fprintf(stderr, "Invalid CRC in Deflate stream: %08x vs %08x\n",
+ 		    crc1, crc2);
+@@ -754,7 +754,7 @@ void *bgzf_decode_thread(void *arg) {
+ 	uint32_t crc1=iolib_crc32(0L, (unsigned char *)j->uncomp, s.total_out);
+ 	uint32_t crc2;
+ 	memcpy(&crc2, j->comp + j->comp_sz, 4);
+-	crc2 = le_int2(crc2);
++	crc2 = le_int4(crc2);
+ 	if (crc1 != crc2) {
+ 	    fprintf(stderr, "Invalid CRC in Deflate stream: %08x vs %08x\n",
+ 		    crc1, crc2);
+@@ -1055,7 +1055,7 @@ static int bam_uncompress_input(bam_file_t *b) {
+ 					    b->uncomp_sz);
+ 		uint32_t crc2;
+ 		memcpy(&crc2, b->comp_p-8, 4);
+-		crc2 = le_int2(crc2);
++		crc2 = le_int4(crc2);
+ 		if (crc1 != crc2) {
+ 		    fprintf(stderr, "Invalid CRC in Deflate stream: "
+ 			    "%08x vs %08x\n", crc1, crc2);
+@@ -1656,7 +1656,8 @@ static int sam_next_seq(bam_file_t *b, bam_seq_t **bsp) {
+ int bam_get_seq(bam_file_t *b, bam_seq_t **bsp) {
+     int32_t blk_size, blk_ret;
+     bam_seq_t *bs;
+-    uint32_t i32;
++    uint32_t u32;
++    int32_t i32;
+ 
+     b->line++;
+ 
+@@ -1701,22 +1702,22 @@ int bam_get_seq(bam_file_t *b, bam_seq_t **bsp) {
+ 
+     bs->blk_size  = blk_size;
+     bs->ref       = le_int4(bs->ref);
+-    bs->pos       = le_int4(bs->pos_32);
++    i32 = le_int4(bs->pos_32); bs->pos = i32;
+ 
+     // order of bit-fields in struct is platform specific, so manually decode
+-    i32           = le_int4(bs->bin_packed);
+-    bs->bin      = i32 >> 16;
+-    bs->map_qual = (i32 >> 8) & 0xff;
+-    bs->name_len = i32 & 0xff;
++    u32           = le_int4(bs->bin_packed);
++    bs->bin      = u32 >> 16;
++    bs->map_qual = (u32 >> 8) & 0xff;
++    bs->name_len = u32 & 0xff;
+ 
+-    i32           = le_int4(bs->flag_packed);
+-    bs->flag      = i32 >> 16;
+-    bs->cigar_len = i32 & 0xffff;
++    u32           = le_int4(bs->flag_packed);
++    bs->flag      = u32 >> 16;
++    bs->cigar_len = u32 & 0xffff;
+ 
+     bs->len       = le_int4(bs->len);
+     bs->mate_ref  = le_int4(bs->mate_ref);
+-    bs->mate_pos  = le_int4(bs->mate_pos_32);
+-    bs->ins_size  = le_int4(bs->ins_size_32);
++    i32 = le_int4(bs->mate_pos_32); bs->mate_pos = i32;
++    i32 = le_int4(bs->ins_size_32); bs->ins_size = i32;
+ 
+     if (10 == be_int4(10)) {
+ 	int i, cigar_len = bam_cigar_len(bs);
+@@ -1734,7 +1735,8 @@ int bam_get_seq(bam_file_t *b, bam_seq_t **bsp) {
+ int bam_get_seq(bam_file_t *b, bam_seq_t **bsp) {
+     int32_t blk_size, blk_ret;
+     bam_seq_t *bs;
+-    uint32_t i32;
++    uint32_t u32;
++    int32_t i32;
+ 
+     b->line++;
+ 
+@@ -1769,22 +1771,22 @@ int bam_get_seq(bam_file_t *b, bam_seq_t **bsp) {
+ 
+     bs->blk_size  = blk_size;
+     bs->ref       = le_int4(bs->ref);
+-    bs->pos       = le_int4(bs->pos_32);
++    i32 = le_int4(bs->pos_32); bs->pos = i32;
+ 
+     // order of bit-fields in struct is platform specific, so manually decode
+-    i32           = le_int4(bs->bin_packed);
+-    bs->bin      = i32 >> 16;
+-    bs->map_qual = (i32 >> 8) & 0xff;
+-    bs->name_len = i32 & 0xff;
++    u32           = le_int4(bs->bin_packed);
++    bs->bin      = u32 >> 16;
++    bs->map_qual = (u32 >> 8) & 0xff;
++    bs->name_len = u32 & 0xff;
+ 
+-    i32           = le_int4(bs->flag_packed);
+-    bs->flag      = i32 >> 16;
+-    bs->cigar_len = i32 & 0xffff;
++    u32           = le_int4(bs->flag_packed);
++    bs->flag      = u32 >> 16;
++    bs->cigar_len = u32 & 0xffff;
+ 
+     bs->len       = le_int4(bs->len);
+     bs->mate_ref  = le_int4(bs->mate_ref);
+-    bs->mate_pos  = le_int4(bs->mate_pos_32);
+-    bs->ins_size  = le_int4(bs->ins_size_32);
++    i32 = le_int4(bs->mate_pos_32); bs->mate_pos = i32;
++    i32 = le_int4(bs->ins_size_32); bs->ins_size = i32;
+ 
+     /* Name */
+     if (bam_read(b, &bs->data, bam_name_len(bs)) != bam_name_len(bs))


=====================================
debian/patches/series
=====================================
@@ -2,3 +2,7 @@ pathmax.patch
 fix_fseeko.patch
 fix_non_x86.patch
 remove_bashism.patch
+d4591b5.patch
+37b33d3.patch
+1b28b6a.patch
+242cd6b.patch


=====================================
debian/rules
=====================================
@@ -35,6 +35,11 @@ override_dh_install-arch:
 	#	 --version-string="$(version)" \
 	#	 $(CURDIR)/debian/$(utils)/usr/bin/srf_filter > $(mandir)/srf_filter.1
 
+override_dh_install-indep:
+ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
+	echo "Do not run test suite for architecture independent builds"
+endif
+
 override_dh_install-indep:
 	dh_install -i
 	mkdir -p $(testdir)



View it on GitLab: https://salsa.debian.org/med-team/staden-io-lib/compare/dd8481532c4a66ab2870a5bf82057cc9af0980c6...ac9ba7548ca657996b9a38933a931cc8210e921c

-- 
View it on GitLab: https://salsa.debian.org/med-team/staden-io-lib/compare/dd8481532c4a66ab2870a5bf82057cc9af0980c6...ac9ba7548ca657996b9a38933a931cc8210e921c
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20181207/24292cb6/attachment-0001.html>


More information about the debian-med-commit mailing list