From owner-freebsd-current Thu Oct 24 4:59:20 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0142237B401 for ; Thu, 24 Oct 2002 04:59:19 -0700 (PDT) Received: from mail03.svc.cra.dublin.eircom.net (mail03.svc.cra.dublin.eircom.net [159.134.118.19]) by mx1.FreeBSD.org (Postfix) with SMTP id 057A443E65 for ; Thu, 24 Oct 2002 04:59:18 -0700 (PDT) (envelope-from pmedwards@eircom.net) Received: (qmail 81566 messnum 527871 invoked from network[159.134.237.90/chester.eircom.net]); 24 Oct 2002 11:59:16 -0000 Received: from chester.eircom.net (HELO webmail.eircom.net) (159.134.237.90) by mail03.svc.cra.dublin.eircom.net (qp 81566) with SMTP; 24 Oct 2002 11:59:16 -0000 From: "Peter Edwards" To: current@freebsd.org Subject: Floating point problems Date: Thu, 24 Oct 2002 12:54:47 +0100 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit X-Originating-IP: 62.17.151.61 X-Mailer: Eircom Net CRC Webmail (http://www.eircom.net/) Organization: Eircom Net (http://www.eircom.net/) Message-Id: <20021024115918.057A443E65@mx1.FreeBSD.org> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hi, There was some discussion about issues with interactions between the floating point context and signal handling in a thread a week or so ago, and a suggestion that someone try and get a simple test that would fail. I was surprised how easy it was: The following program just spins calculating the value of 6.0 / 3.0, and traps SIGINT. If you run it on -current (as of a few hours ago), 99% of the time, hitting ctl-C will cause the program to exit with an error. A 4.5 kernel never causes any problems. I'm pretty sure this is what's causing the stalls and crashes in X. I've taken stack traces of crashes, and from "spinning" processes, and I can spot NaNs on the stack that shouldn't be there, etc. I just thought it might be useful to send this, to firmly take the blame away from the X server, and give someone a way of reproducing the bug. fptest.c: #include #include #include #include int count = 0; void sigint(int sig) { write(2, "INT\n", 4); count++; } int main(int argc, char **argv) { double x = 6.0; double y = 3.0; double d; double err; struct sigaction sa; sa.sa_handler = sigint; sa.sa_flags = 0; sigemptyset(&sa.sa_mask); sigaction(SIGINT, &sa, 0); while (count < 30) { d = x / y; err = 2.0 - d; if (err != 0.0) { fprintf(stderr, "err %f!\n", err); exit(-1); } } } -- Peter Edwards. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message