[Ltrace-devel] [PATCH v3] Fix libunwind support for MIPS

Petr Machata pmachata at gmail.com
Fri Jul 24 16:06:56 UTC 2015


Vicente Olivert Riera <Vincent.Riera at imgtec.com> writes:

> Then I don't understand what you mean, Petr. function_offset is not

This is the new code:

 			rc = unw_get_proc_name(&cursor, fn_name,
 					       sizeof(fn_name),
					       &uw_function_offset);
			function_offset = (arch_addr_t) uw_function_offset;
			assert(uw_function_offset == (unw_word_t) function_offset);
   			if (rc == 0 || rc == -UNW_ENOMEM)

Now imagine that unw_get_proc_name fails.  uw_function_offset is
therefore uninitalized and could contain whatever.  But then you copy
its value over to function_offset.  Since the two can be of different
widths, the value in uw_function_offset may have been trimmed, and the
two end up containing different values.  The assert would then fail.

So either initialize to zero, or just move the code where we know
uw_function_offset was initialized.

Did this help?

Thanks,
Petr



More information about the Ltrace-devel mailing list