Subject: amd64 alignment problem - gcc's fault or libpthread's?
To: None <port-amd64@netbsd.org, tech-toolchain@netbsd.org>
From: Matthias Drochner <M.Drochner@fz-juelich.de>
List: tech-toolchain
Date: 02/27/2004 17:02:24
This is a multipart MIME message.

--==_Exmh_107489574078700
Content-Type: text/plain; charset=us-ascii


Hi -
I've found that programs using "va_start" occasionally
dump core because the vararg code involves "movaps"
instructions, but the stack location is not aliged
properly (needs 16-byte alignment).

I've submitted a bug report to gcc about this (c/14321).

Now, after thinking about it, I'm not quite sure
anymore that this is really gcc's fault.
I could only trigger the problem if the vararg using
code is called from a thread. I don't know the ABI
requirements, but in case a 16-byte stack alignment
is required, and our libpthread doesn't ensure it,
it would be libpthread's fault.

I'll append a small test program which coredumps for me.

Can anyone tell me what stack alignment is required by
the ABI, before I further accuse gcc?

best regards
Matthias



--==_Exmh_107489574078700
Content-Type: text/plain ; name="fptest.c"; charset=us-ascii
Content-Description: fptest.c
Content-Disposition: attachment; filename="fptest.c"

#include <stdio.h>
#include <pthread.h>

char buf[100];

void *
thr(void *p)
{

	sprintf(buf, "%.*g\n", 12, 1.234);
}

main()
{
	pthread_t t;

	pthread_create(&t, 0, thr, 0);
	pthread_join(t, 0);
}

--==_Exmh_107489574078700--