[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MirageOS-devel] Crash on x86 with doubles



On 2 Jul 2014, at 13:04, Thomas Leonard <talex5@xxxxxxxxx> wrote:

> On 2 July 2014 09:02, Anil Madhavapeddy <anil@xxxxxxxxxx> wrote:
>> On 1 Jul 2014, at 22:53, Thomas Leonard <talex5@xxxxxxxxx> wrote:
>> 
>>> I've got printing of floating point values working now on ARM, but
>>> while testing I discovered it crashes on x86.
>>> 
>>> This turned out to be unrelated to OCaml or Mirage. It seems that
>>> passing a double argument to any varargs function causes a crash on
>>> x86_64 if done from a Mini-OS thread. Can any x86 gurus here shed some
>>> light on what might cause that? x86 is a mystery to me.
>> 
>> First thing to check is that %rsp stack alignment is valid when you
>> enter the function, as it's required to be 16-byte aligned by the
>> x86_64 ABI if you're using the XMM registers.
>> 
>> An ancient diff in our local MiniOS that fixed one instance of this
>> is below. (I can't reproduce this instantly to give you a more precise
>> diagnosis as I'm travelling at the moment, apologies!)
> 
> Ah, that was indeed the problem. I changed the x86 arch_create_thread
> to skip 8 bytes and now it works!
> 
> Though, it seemed that it *was* 16-byte aligned before, and is now off
> by 8 bytes, which I don't understand. I'll send the patch to xen-devel
> and they can decide if it's the right fix.

Stack misalignment is the bug that keeps on giving.  It's really easy
for an unrelated change to misalign the stack under some conditions, and
to not notice until a future 16-byte alignment operation happens.

Found several of these in OCaml as well...
http://caml.inria.fr/mantis/view.php?id=5700
http://caml.inria.fr/mantis/view.php?id=6038

Incidentally, I notice that the thread machinery in MiniOS is now active
again.  I removed it from our MiniOS on the basis that it wasn't used
(but there's no harm in leaving it there now).  But that might explain
why the issue cropped up again, as I never tested that code path in
upstream MiniOS.

-anil

_______________________________________________
MirageOS-devel mailing list
MirageOS-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.