[PATCH] Fix libbacktrace on 32-bit sparc
Ian Lance Taylor
iant@google.com
Sun Oct 28 05:12:00 GMT 2012
On Fri, Oct 26, 2012 at 9:27 PM, David Miller <davem@davemloft.net> wrote:
>
> I'm getting a SIGBUS on every backtrace libbacktrace generates
> on 32-bit sparc builds. The crashes usually happen in
> add_function_range(), where 'p' is not 8-byte aligned.
>
> It seems that the vector code doesn't take care to align the pointers
> it returns. I cribbed the size alignment done in mmap.c's
> implementation of backtrace_alloc() to fix this.
Sorry about the problem, but I don't see how this can be the right
fix. A single vector will always be an array of the same struct, so I
don't see how any individual struct can be misaligned. It seems like
increasing the requested size is just going to consistently misalign
any struct that does not require 8 byte alignment, so later references
into the vector using an index will fail. Also backtrace_vector_grow
is based on top of backtrace_alloc, so again aligning the size
shouldn't matter.
The struct used by add_function_range is
struct function_addrs
{
uint64_t low;
uint64_t high;
struct function *function;
};
So on a 32-bit system, this should have a size of 20 if uint64_t
requires 4-byte alignment, but it should have a size of 24 if uint64_t
requires 8-byte alignment. It sounds like uint64_t requires 8-byte
alignment, so the size of this struct should be 24, so your patch
shouldn't change matters. Since your patch presumably works, it
sounds like sizeof (struct function_addrs) is returning 20, but that
does not make sense. It would mean that allocating an array of struct
function_addrs wouldn't work correctly.
So I don't know what is going on.
Ian
More information about the Gcc-patches
mailing list