[med-svn] [Git][med-team/libdozeu][master] 2 commits: Fix build and runtime on 32-bit architectures

Andreas Tille (@tille) gitlab at salsa.debian.org
Mon Nov 9 14:30:27 GMT 2026



Andreas Tille pushed to branch master at Debian Med / libdozeu


Commits:
9329e46a by Andreas Tille at 2026-11-09T15:14:45+01:00
Fix build and runtime on 32-bit architectures

- - - - -
a72e092f by Andreas Tille at 2026-11-09T15:28:10+01:00
Upload to unstable

- - - - -


3 changed files:

- debian/changelog
- + debian/patches/fix_32bit_layout.patch
- debian/patches/series


Changes:

=====================================
debian/changelog
=====================================
@@ -1,3 +1,9 @@
+libdozeu (0.0~git20260825.d0e9ba6-4) unstable; urgency=medium
+
+  * Fix build and runtime on 32-bit architectures
+
+ -- Andreas Tille <tille at debian.org>  Mon, 09 Nov 2026 15:27:04 +0100
+
 libdozeu (0.0~git20260825.d0e9ba6-3) unstable; urgency=medium
 
   * Extend the SSE2 intrinsics fix: pre-include the complete <immintrin.h>


=====================================
debian/patches/fix_32bit_layout.patch
=====================================
@@ -0,0 +1,75 @@
+Description: Fix the 32-bit build: 16-byte layout invariants and pointer-size casts
+ dozeu.h keeps several ''__m128i''-related invariants that only held on 64-bit
+ targets, where pointers are 8 bytes wide:
+ .
+  * struct dz_query_s was 44 bytes on 32-bit instead of 48: arr[] (loaded and
+    stored through aligned __m128i vector ops, and required to stay exactly
+    sizeof(bonus) after it) was no longer 16-byte aligned, and the size was not
+    a multiple of 16 (failing dz_static_assert, i.e. "size of array '_st_' is
+    negative").
+  * struct dz_node_s was 12 bytes instead of 16.
+  * struct dz_forefront_s was 56 bytes instead of 64 (failing the size assert,
+    and breaking the dz_head_s/dz_cap_s/dz_forefront_s "fr" interchangeability
+    assumptions used by the traceback).
+  * struct dz_mem_s was 40 bytes instead of a 16-multiple, so
+    dz_mem(self) = self - sizeof(struct dz_mem_s) no longer recovered the arena
+    header after dz_mem_flush's 16-byte rounding of stack.top, corrupting the
+    stack state at runtime.
+ .
+ Pad these with pointer-size-conditional fields / aligned(16) so the layouts
+ become identical on 32-bit and 64-bit (a no-op on 64-bit), and parse nm
+ addresses through uintptr_t in the unit test so the header compiles without
+ -Wint-to-pointer-cast on 32-bit.
+Author: Andreas Tille <tille at debian.org>
+Last-Update: 2026-11-09
+Assisted-By: scaleway/deepseek-v4-flash-0731
+
+--- a/dozeu.h
++++ b/dozeu.h
+@@ -205,13 +205,16 @@ struct dz_query_s {
+     uint32_t blen;
+     uint32_t arr_end;
+     char const *q;
++#if UINTPTR_MAX == UINT32_MAX
++    uint32_t _pad;  /* keep bonus/arr layout and sizeof a multiple of 16 on 32-bit */
++#endif
+     int16_t bonus[16];
+     uint8_t arr[];
+ };
+ dz_static_assert(sizeof(struct dz_query_s) % sizeof(__m128i) == 0);
+ 
+ /* node (reference) */
+-struct dz_node_s { int32_t id, len; uint8_t const *ptr; };
++struct dz_node_s { int32_t id, len; uint8_t const *ptr; } __attribute__((aligned(16)));
+ dz_static_assert(sizeof(struct dz_node_s) % sizeof(__m128i) == 0);
+ 
+ /* DP matrix structures */
+@@ -277,7 +280,7 @@ struct dz_forefront_s {
+     uint8_t _pad[8];
+ 	struct dz_query_s const *query;
+ 	struct dz_cap_s const *mcap;
+-};
++} __attribute__((aligned(16)));
+ /*
+  * When initializing forefronts, we want to be able to fill in the pad without saying 0s everywhere.
+  */
+@@ -344,7 +347,7 @@ struct dz_stack_s { struct dz_mem_block_s *curr; uint8_t *top, *end; uint64_t be
+  * Exists at the beginning of the arena's first block, and contains its block
+  * header and also its stack bookkeeping information.
+  */
+-struct dz_mem_s { struct dz_mem_block_s blk; struct dz_stack_s stack; };
++struct dz_mem_s { struct dz_mem_block_s blk; struct dz_stack_s stack; } __attribute__((aligned(16)));
+ /* Compute the number of bytes available to allocate in the current active block of an arena. */
+ #define dz_mem_stack_rem(_mem)		( (size_t)((_mem)->stack.end - (_mem)->stack.top) )
+ 
+--- a/unittest.h
++++ b/unittest.h
+@@ -701,7 +701,7 @@
+ 		/* if the first character of the line is space, pass the PTR state */
+ 		if(!isspace(*p)) {
+ 			char *np;
+-			r.ptr = (void *)((uint64_t)strtoll(p, &np, 16));
++			r.ptr = (void *)(uintptr_t)strtoull(p, &np, 16);
+ 
+ 			/* advance pointer */
+ 			p = np;


=====================================
debian/patches/series
=====================================
@@ -1 +1,2 @@
 use_native_smmintrin_on_sse4_1_x86.patch
+fix_32bit_layout.patch



View it on GitLab: https://salsa.debian.org/med-team/libdozeu/-/compare/71e35f6b51d60f67002821e4ad89ac2cb00d14f9...a72e092f40c3df51863a9b71f922a911635e7b82

-- 
View it on GitLab: https://salsa.debian.org/med-team/libdozeu/-/compare/71e35f6b51d60f67002821e4ad89ac2cb00d14f9...a72e092f40c3df51863a9b71f922a911635e7b82
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20261109/5f61b859/attachment-0001.htm>


More information about the debian-med-commit mailing list