Hi,

I don't know whether it's been already reported or not, so anyway.
There are places in SQLite where unaligned access exception is
generated on Itanium. The unaligned access means that someone tries to
read or write memory crossing 8-bytes boundary. Usually this occur as
a result of pointers casting.

I investigated it a little bit and found that the reason is this line
in func.c file:

      p->sum += sqlite3_value_int64(argv[0]);

It is a part of sumStep function. p->sum is long double, that is 16
bytes size. It means that it must be aligned on 16 bytes boundary, but
it is 0x6000000000094248 in my case. The reason it is not aligned is
that address returned by sqlite3_aggregate_context is not aligned on
16 bytes boundary which is a must for ia64 systems and which is the
alignment of malloc returned pointers.

So the reason comes to Mem structure and I can see that zShort member
is not forced to be aligned on 16 bytes and in fact it is aligned on 8
bytes.

This is where I got stuck because I don't know whether Mem structure
is on-disk structure or not. Is it OK to change it?

P.S. To catch the unaligned access on Itanium, the easiest way is to say

prctl --unaligned=signal
ulimit -c unlimited

After that unaligned access will cause SIGBUS and core dump will be generated.

P.P.S. Unaligned access can lead to serious performance degradations
and on some OSes (HP-UX) there isn't default unaligned access handler
so it will just crash.

--
Alexei Alexandrov

Reply via email to