Varargs issues

James Van Artsdalen james-freebsd-amd64 at jrv.org
Mon Dec 1 14:08:41 PST 2003


I don't have my Opteron hardware yet but I did build a gcc
cross-compiler to look at your earlier bug report.

When a function takes a variable number of arguments it appears
that the caller passes, among other things, the number of floating
point values passed in registers as opposed to on the stack.
The function prologue writes those registers to stack slots so
var_args can refer to them later.

The function prologue writes these floats to stack slots with the
MOVAPS opcode.  The "AMD64 Architecture Programmer's Manual Volume 4:
128-Bit Media Instructions" manual states "A memory operand that is
not aligned on a 16-byte boundary causes a general protection
exception" for MOVAPS.

The trick is that gcc 3.3 doesn't seem to try to keep the stack
aligned to 16-bytes, so on entry to a function the stack may be 8-byte
aligned, 16-byte aligned, etc.  If the AMD book is not out-of-date
then a fault is bound to happen on MOVAPS at some point.

This problem with this theory of course is that I'd expect a lot of
crashes, more than are apparently being seen.  I don't have the
documentation on the ABI calling conventions so I'm just guessing
based on gcc's output (and I might not be using the right compiler).

If you can build an x86-64 gdb you might look at a core dump and tell
me what opcode generated the fault (either symbolic or in hex) and the
value in %rsp.

From: Adriaan de Groot <adridg at cs.kun.nl>
Subject: Varargs issues
To: freebsd-amd64 at freebsd.org

[aside: most-recent cvsup doesn't compile without options SMP, due to that
mp_maxid issue]

amd64/59650 is a PR of mine that I'd like to pimp for attention. The
real and present effect is that the ogg123 program from the vorbis-tools
port bus errors, but there's several test programs - even a short one - in
the PR. The problem still persists in a system rebuilt on the 23rd, and
I'm still waiting to see if today's builds are stable (ie. boot at all) to
test it on that.

The problem with the problem is that (a) I've no idea if I'm linking
everything correcly or need to do other thread magic (if so, the ogg12 app
has the same issues) and (b) I only have one amd64 box, so there's
a chance that the problem is purely local, even. Could someone, anyone,
run the test program in order to confirm (or deny) the problem? 'cause if
it _is_ a problem, then it potentially affects any application that does
threading.


More information about the freebsd-amd64 mailing list