From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.lisp.guile.devel Subject: Re: Serious bug in GUILE rational handling. Date: Sun, 24 Dec 2006 10:21:45 +1100 Message-ID: <87slf66vw6.fsf@zip.com.au> References: <458D900F.1020108@xs4all.nl> NNTP-Posting-Host: dough.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1166916116 16555 80.91.229.10 (23 Dec 2006 23:21:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 23 Dec 2006 23:21:56 +0000 (UTC) Cc: schottstaedt@ccrma.stanford.edu, guile-devel@gnu.org, Jan Nieuwenhuizen Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Dec 24 00:21:54 2006 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by dough.gmane.org with esmtp (Exim 4.50) id 1GyGBd-0004kW-M1 for guile-devel@m.gmane.org; Sun, 24 Dec 2006 00:21:53 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GyGBd-0002y4-4C for guile-devel@m.gmane.org; Sat, 23 Dec 2006 18:21:53 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GyGBb-0002wN-5m for guile-devel@gnu.org; Sat, 23 Dec 2006 18:21:51 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GyGBY-0002rZ-T1 for guile-devel@gnu.org; Sat, 23 Dec 2006 18:21:50 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GyGBY-0002rQ-OT for guile-devel@gnu.org; Sat, 23 Dec 2006 18:21:48 -0500 Original-Received: from [61.8.2.231] (helo=mailout2.pacific.net.au) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GyGBX-0000EN-2d; Sat, 23 Dec 2006 18:21:47 -0500 Original-Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.2.163]) by mailout2.pacific.net.au (Postfix) with ESMTP id 282B26E083; Sun, 24 Dec 2006 10:21:44 +1100 (EST) Original-Received: from localhost (ppp2F33.dyn.pacific.net.au [61.8.47.51]) by mailproxy2.pacific.net.au (Postfix) with ESMTP id E02AC2740C; Sun, 24 Dec 2006 10:21:44 +1100 (EST) Original-Received: from gg by localhost with local (Exim 4.63) (envelope-from ) id 1GyGBV-0001qh-CR; Sun, 24 Dec 2006 10:21:45 +1100 Original-To: hanwen@xs4all.nl Mail-Copies-To: never In-Reply-To: <458D900F.1020108@xs4all.nl> (Han-Wen Nienhuys's message of "Sat, 23 Dec 2006 21:22:39 +0100") User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:6358 Archived-At: Han-Wen Nienhuys writes: > > This took a lot of effort to debug; printing the rational while > debugging would alter the reduction bit, making the problem go away, > suggesting memory corruption rather than a programming error. Nasty. > Suppose another thread triggers scm_i_fraction_reduce at the same > time, and reads the partial result of the first scm_i_fraction_reduce. > This is really insidious, as the corruption would happen upon reading > the data, and will show up somewhere completely different. Yep. I think I might have raised that when fractions were introduced, then promptly never did anything about it. My best idea at the time was if fractions are stored unreduced then gc would be a good thread-safe place to look for reductions to save space. I don't know if reduced or unreduced is a better representation. My guess would be that gcds are so horrendously expensive that unreduced is often what you want, if it's do-able. Reducing lazily sounds like the best of both worlds, but as you point out would need multithread protection. > I am about to commit these changes to CVS, and will also commit them > to the GUILE 1.8 branch. Do you have a test case for numbers.test? Not that I doubt the fix, just to illustrate what now works. I took the liberty of adding a NEWS entry too. _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel