From owner-freebsd-amd64@FreeBSD.ORG Wed Nov 26 05:30:25 2003 Return-Path: Delivered-To: freebsd-amd64@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D76EA16A4CF for ; Wed, 26 Nov 2003 05:30:25 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3595643FDD for ; Wed, 26 Nov 2003 05:30:24 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id hAQDUNFY061787 for ; Wed, 26 Nov 2003 05:30:23 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id hAQDUNbg061786; Wed, 26 Nov 2003 05:30:23 -0800 (PST) (envelope-from gnats) Date: Wed, 26 Nov 2003 05:30:23 -0800 (PST) Message-Id: <200311261330.hAQDUNbg061786@freefall.freebsd.org> To: freebsd-amd64@FreeBSD.org From: Adriaan de Groot Subject: Re: amd64/59650: passing float parameters in non-main threads bus errors X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Adriaan de Groot List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Nov 2003 13:30:26 -0000 The following reply was made to PR amd64/59650; it has been noted by GNATS. From: Adriaan de Groot To: freebsd-gnats-submit@FreeBSD.org Cc: Subject: Re: amd64/59650: passing float parameters in non-main threads bus errors Date: Wed, 26 Nov 2003 14:23:10 +0100 Some further debugging shows that it's not even sprintf() of va_start() specific, but just passing float / double arguments to a varargs function in a non-main thread of control triggers bus errors already: /* ** Demonstration program that float parameters to ** varargs functions in non-main threads of ** control on amd64 does not work properly. */ #include #include #include /* ** This is a varargs function to which we will attempt to pass ** a float value in the ... . */ int PrintF(int fd, const char *fmt, int i, ...) { int ret = 2; fprintf(stderr,"[%lx]B %d\n",(long)pthread_self(),fd); return ret; } /* ** Demonstration function. Expected output is something like ** ** [504000]B 0 ** [504000]B 1 ** [504000]B 2 ** [504000]B 3 ** ** From the 4 calls to PrintF(). This bus errors in the third ** call when not in the main thread of control. */ void *threadfunc(void *p) { PrintF(0,"hello",0,0); PrintF(1,"hello",0,6); PrintF(2,"hello",1,0.00028376223); /* arg4 is a float */ PrintF(3,"hello",0.00028376223,6); /* arg3 converts to int here */ return p; } int main(int argc, char **argv) { pthread_t tid; threadfunc(NULL); pthread_create(&tid,NULL,threadfunc,NULL); sleep(4); threadfunc(NULL); return 0; } Now, either I'm doing something totally moronic with threads (and the ogg123 port is too) or the argument passing is seriously broken. I might be compiling it wrong, though: beans.ebn.kun.nl$gcc -o threadtest -g v.c -lc_r && ./threadtest [504000]B 0 [504000]B 1 [504000]B 2 [504000]B 3 [504800]B 0 [504800]B 1 Bus error (core dumped) The machine has been updated in -CURRENT since the original bug report: FreeBSD beans.ebn.kun.nl 5.2-BETA FreeBSD 5.2-BETA #2: Sun Nov 23 19:48:43 CET 2003 root@beans.ebn.kun.nl:/usr/obj/mnt/sys/CURRENT/src/sys/BEANS amd64 -- pub 1024D/FEA2A3FE 2002-06-18 Adriaan de Groot If the door is ajar, can we fill it with door-jamb?