Bug#932090: firebird3.0: Please include patch to ensure correct sizes of on-disk structures

2024-03-16 Thread Thorsten Glaser
John Paul Adrian Glaubitz dixit:

>However, it turns out that my approach is wrong and upstream has already used
>a different approach for firebird4.0 [2], although I haven't tested that on
>m68k yet.

>> [2] https://github.com/FirebirdSQL/firebird/pull/234/commits

(use https://github.com/FirebirdSQL/firebird/pull/234.patch in lynx)

Very much not; firebird3.0 also has that now AFAICT, and now the static
asserts fail.

The alignment assumptions must be made explicit: change something like…

struct foo {
char a;
int b;
};

… to:

struct foo {
char a;
char padding1[3];
int b;
};

bye,
//mirabilos
-- 
When he found out that the m68k port was in a pretty bad shape, he did
not, like many before him, shrug and move on; instead, he took it upon
himself to start compiling things, just so he could compile his shell.
How's that for dedication. -- Wouter, about my Debian/m68k revival



Bug#932090: firebird3.0: Please include patch to ensure correct sizes of on-disk structures

2022-05-11 Thread John Paul Adrian Glaubitz
Hi Damyan!

On 6/26/20 08:40, Damyan Ivanov wrote:
> Can you tell me where was the patch forwarded? I want to check whether 
> it is part of some upstream branch before applying it to the debian 
> package.

Patch and discussion can be found here [1].

However, it turns out that my approach is wrong and upstream has already used
a different approach for firebird4.0 [2], although I haven't tested that on
m68k yet.

Will test later.

Adrian

> [1] https://github.com/FirebirdSQL/firebird/pull/217
> [2] https://github.com/FirebirdSQL/firebird/pull/234/commits

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913



Bug#932090: firebird3.0: Please include patch to ensure correct sizes of on-disk structures

2020-06-25 Thread Damyan Ivanov
Hello Adrian,

Sorry for the late reply.

-=| John Paul Adrian Glaubitz, 15.07.2019 00:41:49 +0200 |=-
> Source: firebird3.0
> Version: 3.0.5.33100.ds4-3
> Severity: normal
> Tags: patch
> User: debian-...@lists.debian.org
> Usertags: m68k
> 
> firebird3.0 currently fails to build from source on m68k because the native
> alignment of 16 bits on this architecture causes the on-disk structures to
> have unexpected sizes.
> 
> With the attached patch, padding is added to the affected on-disk structures
> such that the correct sizes are always guaranteed. Since this particular
> padding happens automatically and implicitly for architectures with 32 or
> 64 bits native alignment, the actual sizes and offsets of the on-disk
> structures do not change and therefore no compatibility break is going
> to occur.
> 
> Using explicit padding has the advantage that the actual sizes and offsets
> are completely visible and transparent to anyone reading the code.
> 
> I will forward this patch upstream.

Can you tell me where was the patch forwarded? I want to check whether 
it is part of some upstream branch before applying it to the debian 
package.


Thanks,
Damyan



Bug#932090: firebird3.0: Please include patch to ensure correct sizes of on-disk structures

2019-07-14 Thread John Paul Adrian Glaubitz
Source: firebird3.0
Version: 3.0.5.33100.ds4-3
Severity: normal
Tags: patch
User: debian-...@lists.debian.org
Usertags: m68k

Hi!

firebird3.0 currently fails to build from source on m68k because the native
alignment of 16 bits on this architecture causes the on-disk structures to
have unexpected sizes.

With the attached patch, padding is added to the affected on-disk structures
such that the correct sizes are always guaranteed. Since this particular
padding happens automatically and implicitly for architectures with 32 or
64 bits native alignment, the actual sizes and offsets of the on-disk
structures do not change and therefore no compatibility break is going
to occur.

Using explicit padding has the advantage that the actual sizes and offsets
are completely visible and transparent to anyone reading the code.

I will forward this patch upstream.

Thanks,
Adrian

--
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
Description: Add padding for on-disk structures
 In order to guarantee that the on-disk structures have always the expected
 sizes, we should use padding fields within these structs rather than relying
 on the native alignment of the target architecture which can result in
 unexpected sizes for architectures with unusual native alignment.
 .
Author: John Paul Adrian Glaubitz 
Last-Update: 2019-07-14

Index: firebird3.0-3.0.5.33100.ds4/src/jrd/ods.h
===
--- firebird3.0-3.0.5.33100.ds4.orig/src/jrd/ods.h
+++ firebird3.0-3.0.5.33100.ds4/src/jrd/ods.h
@@ -423,6 +423,7 @@ struct header_page
SLONG hdr_att_high; // High word of the 
next attachment counter
USHORT hdr_tra_high[4]; // High words of the 
transaction counters
UCHAR hdr_data[1];  // Misc data
+   USHORT hdr_padding; // Padding
 };
 
 #define HDR_SIZE static_cast(offsetof(Ods::header_page, 
hdr_data[0]))
@@ -479,6 +480,7 @@ struct page_inv_page
ULONG pip_extent;   // Lowest free extent
ULONG pip_used; // Number of pages allocated 
from this PIP page
UCHAR pip_bits[1];
+   USHORT pip_padding; // Padding
 };
 
 
@@ -530,6 +532,7 @@ struct pointer_page
USHORT ppg_count;   // Number of slots active
USHORT ppg_relation;// Relation id
USHORT ppg_min_space;   // Lowest slot with space available
+   USHORT ppg_padding; // Padding
ULONG ppg_page[1];  // Data page vector
 };
 
@@ -564,6 +567,7 @@ struct tx_inv_page
pag tip_header;
ULONG tip_next; // Next transaction inventory 
page
UCHAR tip_transactions[1];
+   USHORT tip_padding; // Padding
 };
 
 
@@ -588,6 +592,7 @@ struct rhd
USHORT rhd_flags;   // flags, etc
UCHAR rhd_format;   // format version
UCHAR rhd_data[1];  // record data
+   USHORT rhd_padding; // padding
 };
 
 #define RHD_SIZE static_cast(offsetof(Ods::rhd, rhd_data[0]))
@@ -603,6 +608,7 @@ struct rhde
UCHAR rhde_format;  // format version   // 
until here, same as rhd
USHORT rhde_tra_high;   // higher bits of transaction id
UCHAR rhde_data[1]; // record data
+   USHORT rhde_padding;// padding
 };
 
 #define RHDE_SIZE static_cast(offsetof(Ods::rhde, rhde_data[0]))
@@ -634,6 +640,7 @@ struct blh
USHORT blh_max_segment; // Longest segment
USHORT blh_flags;   // flags, etc
UCHAR blh_level;// Number of address levels, 
see blb_level in blb.h
+   USHORT blh_padding; // Padding
ULONG blh_count;// Total number of segments
ULONG blh_length;   // Total length of data
USHORT blh_sub_type;// Blob sub-type
Index: firebird3.0-3.0.5.33100.ds4/src/misc/ods.txt
===
--- firebird3.0-3.0.5.33100.ds4.orig/src/misc/ods.txt
+++ firebird3.0-3.0.5.33100.ds4/src/misc/ods.txt
@@ -87,6 +87,7 @@ hdr_crypt_plugin 88
 hdr_att_high 120
 hdr_tra_high 124
 hdr_data 132
+hdr_padding 134
 
  *** struct page_inv_page 32
 pip_header 0
@@ -94,6 +95,7 @@ pip_min 16
 pip_extent 20
 pip_used 24
 pip_bits 28
+pip_padding 30
 
  *** struct scns_page 24
 scn_header 0
@@ -107,12 +109,14 @@ ppg_next 20
 ppg_count 24
 ppg_relation 26
 ppg_min_space 28
+ppg_padding 30
 ppg_page 32
 
  *** struct tx_inv_page 24
 tip_header 0