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

[Xen-devel] mini-os: x86_64: crash passing double arguments



I noticed that passing a double argument to a varargs function on
x86_64 causes Mini-OS to crash. This only happens when called from a
thread, not when using the boot stack.

Here's my test case:

static void foo(char *fmt, ...) { }

static void float_tester(void *p)
{
    printk("Running tests...\n");
    foo("%d", 3);
    printk("Pass int.\n");
    foo("%f", 3.1);
    printk("Pass float.\n");
}

When run from test.c's app_main directly, it passes, but when run from
a thread it crashes:

    (d22) Running tests...
    (d22) Pass int.
    (d22) GPF rip: 0000000000006b04, error_code=0
    (d22) Thread: float
    (d22) RIP: e030:[<0000000000006b04>]

Subtracting 8 bytes from thread->sp when creating a new thread fixes
it (patch attached), but I'm not sure whether this is the right
solution, or whether there's a problem elsewhere (I know very little
about x86).

My test-case and fix/work-around are here:

https://github.com/talex5/xen/commits/stack-fix-x86

Thanks,


-- 
Dr Thomas Leonard        http://0install.net/
GPG: 9242 9807 C985 3C07 44A6  8B9A AE07 8280 59A5 3CC1
GPG: DA98 25AE CAD0 8975 7CDA  BD8E 0713 3F96 CA74 D8BA

Attachment: 0001-mini-os-x86_64-make-thread-stacks-16-byte-aligned.patch
Description: Text Data

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

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