[Mono-dev] Assert error for unaligned access in unwind.c

Zoltan Varga vargaz at gmail.com
Fri Jul 15 16:45:20 UTC 2016


Hi,

  Should be fixed by:

https://github.com/mono/mono/commit/1ad5c0a021e3ff2bffd5a0531f492ddc7cace877

Unfortunately, some arm cpu-s behave unpredictably instead of faulting when
encountering unaligned loads/stores.
As for big-endian, we don't support big-endian arm so that assert
triggering is not a problem.

        Zoltan

On Fri, Jul 15, 2016 at 9:47 AM, Henry Margies <henry.margies at gmail.com>
wrote:

> Hi all,
>
> I’m running into a strange problem when trying to use Mono 4.4.1.0 on an
> ARM architecture.
>
> When I try to execute a Mono application or simply run mcs, I get the
> following output:
>
> # mcs
> * Assertion at unwind.c:385, condition `read16 (p) == (guint32)(op->when
> - loc)' not met
>
> Stacktrace:
>
>
> Native stacktrace:
>
>
> Debug info from gdb:
>
>
> =================================================================
> Got a SIGABRT while executing native code. This usually indicates
> a fatal error in the mono runtime or one of the native libraries
> used by your application.
> =================================================================
>
> Aborted
>
>
> The same application and mcs work fine with Mono 4.0.2, I used a while
> ago. Looking at the source code in mono/mini/unwind.c in function
> mono_unwind_ops_encode_full, I can see that the code tries to cast a
> pointer to a guint16 or guint32 pointer, which will fail on (my) ARM when
> the address is not aligned (lines 378 and 384).
>
> } else if (op->when - loc > 256) {
> *p ++ = DW_CFA_advance_loc2;
> *(guint16*)p = (guint16)(op->when - loc);
> g_assert (read16 (p) == (guint32)(op->when - loc));
>
>
> What is interesting, is that the g_assert is using the read16 macro, which
> deals with alignment issues and also endianness. But with this, I can’t
> really see how the code would work successfully with big endianness either.
>
> The code in question hasn’t changed between 4.0 and 4.4 but the pointer
> casting is only executed when “op->when - loc > 256” is true. So I wonder
> why this changed for me between 4.0 and 4.4 and if I’m even supposed to run
> into these cases on an ARM architecture? When I fix the two problems,
> everything seems to run fine.
>
> Because I don’t think that I’m the first to try to execute “mcs” or run a
> Mono application on an ARM architecture, I kind of blame my build system. I
> use buildroot and run my system on an ARM 926 device. Unfortunately, I have
> no idea what the code in mono_unwind_ops_encode_full actually does and
> when op->when - loc would actually be greater than 256.
>
> I hope that someone here could give me some pointers on why the if
> condition could be true and never was before or in fact is not true for any
> ARM device, so I can check my build system.
>
>
> Thanks,
>
> Henry
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.dot.net
> http://lists.dot.net/mailman/listinfo/mono-devel-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dot.net/pipermail/mono-devel-list/attachments/20160715/c3961839/attachment.html>


More information about the Mono-devel-list mailing list