From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: Goops & Valgrind Date: Mon, 18 Aug 2008 11:58:27 -0700 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1219166307 6973 80.91.229.12 (19 Aug 2008 17:18:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 19 Aug 2008 17:18:27 +0000 (UTC) Cc: guile-devel@gnu.org To: hanwen@xs4all.nl Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Aug 19 19:19:19 2008 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KVUr7-000635-Vn for guile-devel@m.gmane.org; Tue, 19 Aug 2008 19:18:54 +0200 Original-Received: from localhost ([127.0.0.1]:39156 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KVUqA-0006zT-PW for guile-devel@m.gmane.org; Tue, 19 Aug 2008 13:17:54 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KVUq5-0006zN-8E for guile-devel@gnu.org; Tue, 19 Aug 2008 13:17:49 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KVUq2-0006vt-EX for guile-devel@gnu.org; Tue, 19 Aug 2008 13:17:48 -0400 Original-Received: from [199.232.76.173] (port=42715 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KVUq2-0006vd-5R for guile-devel@gnu.org; Tue, 19 Aug 2008 13:17:46 -0400 Original-Received: from a-sasl-quonix.sasl.smtp.pobox.com ([208.72.237.25]:64575 helo=sasl.smtp.pobox.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KVUq2-0000ro-QW for guile-devel@gnu.org; Tue, 19 Aug 2008 13:17:46 -0400 Original-Received: from localhost.localdomain (localhost [127.0.0.1]) by a-sasl-quonix.sasl.smtp.pobox.com (Postfix) with ESMTP id 1569560226; Tue, 19 Aug 2008 13:16:03 -0400 (EDT) Original-Received: from unquote (c-76-105-207-11.hsd1.or.comcast.net [76.105.207.11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-sasl-quonix.sasl.smtp.pobox.com (Postfix) with ESMTPSA id 58B9C60223; Tue, 19 Aug 2008 13:16:00 -0400 (EDT) In-Reply-To: (Han-Wen Nienhuys's message of "Sat, 16 Aug 2008 02:15:17 -0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-Pobox-Relay-ID: 803A988E-6E12-11DD-841A-3113EBD4C077-02397024!a-sasl-quonix.pobox.com X-detected-kernel: by monty-python.gnu.org: Solaris 10 (beta) 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:7471 Archived-At: Hi Han-Wen, On Fri 15 Aug 2008 22:15, Han-Wen Nienhuys writes: > Running the test suite through valgrind, I get some fishy errors. > > Can someone shed a light on this? The culprit seems to be > > #define SCM_NUMBER_OF_SLOTS(x) \ > ((SCM_STRUCT_DATA (x)[scm_struct_i_n_words]) - scm_struct_n_extra_words) > > where scm_struct_i_n_words is -2 Classes that are not metaclasses allocate their instances using "light structs". So the object layout goes like this: the vtable word the data word +-------------------------------+---------------------+ SCM of object = |SCM of class | scm_tc3_struct | SCM* array of slots | +-------------------------------|---------------------+ For classes, the SCM* points to the middle of a SCM array, which has some number of words before 0; 4 words normally, or 6 if the object is an "entity", like a generic function. But for objects there are no words before 0, hence the valid valgrind error. i = scm_to_unsigned_integer (index, 0, SCM_NUMBER_OF_SLOTS(obj)-1); There could be two fixes. One would be to assume that the Scheme code that calls %fast-slot-ref et al is well-formed, and thus we need no bounds checking. It's all in goops.scm, so this would be a decent assumption. The other would be to use a different definition of SCM_NUMBER_OF SLOTS, which would probably have a different purpose: #define SCM_NUMBER_OF_FIELDS(x) (SCM_STRUCT_VTABLE (x)[scm_si_nfields]) Cheers, Andy -- http://wingolog.org/