[Ltrace-devel] [PATCH] Fix libunwind support for MIPS
Petr Machata
pmachata at gmail.com
Wed Jul 15 21:09:59 UTC 2015
Vicente Olivert Riera <Vincent.Riera at imgtec.com> writes:
> /* Verify that we can safely cast arch_addr_t* to unw_word_t*. */
> (void)sizeof(char[1 - 2*(sizeof(unw_word_t) != sizeof(arch_addr_t))]);
>
> This check will always fail for MIPS 32-bit architectures (the only ones
> supported by ltrace) because unw_word_t is 64-bit sized (it's actually a
> uint64_t) and arch_add_t (which is void*) is 32-bit sized:
>
> output.c:784:3: error: size of unnamed array is negative
>
> However, since unw_word_t is always 64-bit sized for any MIPS
> architecture, the casting from arch_addr_t to unw_word_t will always be
> possible, so let's disable this check for MIPS architectures.
The problem is casting of one pointer type to another. The fact that
unw_word_t is 64-bit while arch_addr_t 32-bit is exactly the problem,
because a code seeing unw_word_t* might validly expect that it points to
a 64-bit quantity, while in reality it's only backed by a 32-bit one.
You might build without unwinding support, or alternatively if this
bothers you, tweak the code so that instead of this:
(void)sizeof(char[1 - 2*(sizeof(unw_word_t) != sizeof(arch_addr_t))]);
[...]
arch_addr_t ip;
int rc = unw_get_reg(&cursor, UNW_REG_IP, (unw_word_t *) &ip);
It does something like this:
uwn_word_t uw_ip;
int rc = unw_get_reg(&cursor, UNW_REG_IP, &uw_ip);
arch_addr_t ip = (arch_addr_t) ip;
assert(uw_ip == (uwn_word_t) up);
And similarly for unw_get_proc_name. Such patch would be acceptable as
far as I'm concerned. (Though that doesn't say much, as I've been
neglecting ltrace lately.)
Thanks,
Petr
More information about the Ltrace-devel
mailing list