[Lazarus] RE : RE : RE : RE :RE:RE:FPC_REQUIRES_PROPER_ALIGNMENTdefinedonSolariscausescrashinlazarus

Ludo Brands ludo.brands at free.fr
Sun Jul 10 12:12:09 CEST 2011


> 
> Now tested with a non-trivial program on both ARM on Qemu and running 
> natively on an NSLU2 "Slug" (describes itself as XScale-IXP42x, for 
> completeness little-endian). No obvious issues on either ARM or SPARC.
> 

Good. I've been running lazarus a while on Debian etch on a qemulated Sparc
without any problems neither (other than waiting for the 250 bogomips to
move on).

> Do you think you could explain why you started having 
> alignment problems 
> on x86 Solaris when x86 Linux is OK? And what does 
> FPC_REQUIRES_PROPER_ALIGNMENT actually do- I noticed it when 
> I started 
> working through the MIPS code generation.
> 

The FPC_REQUIRES_PROPER_ALIGNMENT define indicates that the cpu requires
aligned data. This define causes several type definitions to be non packed.
Packed records can violate alignment constraints. 

The compiler sets FPC_REQUIRES_PROPER_ALIGNMENT for Solaris, independent of
the cpu used. So, fe. TPropData is packed on x86 linux and aligned on x86
solaris. The first series of lazarus crashes seen on solaris x86 and solaris
sparc are linked to the fact that lazarus assumed TPropData to be aligned
and did some pointer arethmic to get to the different record members. Since
the alignment put the record members (pointers in this case) on a different,
aligned, location, x86 crashed with a wrong pointer (SIGSEGV) and sparc with
an unaligned access (SIGBUS). In other words, if the compiler hadn't set
FPC_REQUIRES_PROPER_ALIGNMENT for solaris x86 then these problems wouldn't
have popped up.

The second type of alignment problems as seen in synregexpr didn't raise
their head on solaris x86 because the data is simply unaligned. No wrong
pointers. Synregedit uses pointer arithmetic to create and run a kind of
state machine and doesn't have a notion of alignment. So a lot of unaligned
data but solaris x86 doesn't bother. Sparc and Arm do. The patch I made for
synregexpr assures proper alignment for pointers in the state machine data
structure. 

Ludo





More information about the Lazarus mailing list