From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: No Itisnt Newsgroups: gmane.lisp.guile.devel Subject: RE: Valgrind fix Date: Mon, 8 Mar 2010 12:49:48 -0600 Message-ID: <1e54fa2e1003081049x4b153674q20e983bcc98262b0@mail.gmail.com> References: <1e54fa2e1003071604w3de9e887w94c3615462935ca9@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=00163630eecf8a47ed04814e8791 X-Trace: dough.gmane.org 1268074207 3809 80.91.229.12 (8 Mar 2010 18:50:07 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 8 Mar 2010 18:50:07 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Mar 08 19:50:03 2010 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.69) (envelope-from ) id 1Noi1b-0001Gm-6E for guile-devel@m.gmane.org; Mon, 08 Mar 2010 19:49:55 +0100 Original-Received: from localhost ([127.0.0.1]:57243 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Noi1a-00029P-KD for guile-devel@m.gmane.org; Mon, 08 Mar 2010 13:49:54 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Noi1X-00028i-VQ for guile-devel@gnu.org; Mon, 08 Mar 2010 13:49:51 -0500 Original-Received: from [140.186.70.92] (port=56758 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Noi1W-00027m-Bi for guile-devel@gnu.org; Mon, 08 Mar 2010 13:49:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Noi1V-0007KU-6Y for guile-devel@gnu.org; Mon, 08 Mar 2010 13:49:50 -0500 Original-Received: from qw-out-1920.google.com ([74.125.92.150]:30811) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Noi1V-0007KM-4D for guile-devel@gnu.org; Mon, 08 Mar 2010 13:49:49 -0500 Original-Received: by qw-out-1920.google.com with SMTP id 5so2023835qwc.24 for ; Mon, 08 Mar 2010 10:49:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=EaV/Ri0tOlw/njgZLjzVLi1qpf/sRIuFdTUMo24X6iU=; b=lUlIn3JpElHs7WOxfwghPtQoPnN8K9eoCQ0ezteuocpRmWE4JR7b7N0BSGZl91erDT KOPDdXALFr0KWPBnCSj2aqJwgHDMj8CCPY1Lk+Wb9d/Ku7UBadNO1X7kXN3m5Uz0EkQ+ /7GsVGXAM+WSC4c8JVF0QHnxGYnk8dAMm7b0s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=HONpPo4k76WpCF9H/z37bxbddzjfIvGsg4ADOvsGX29arXu2iSCNz+vKTe7ZIn+TN+ by1oeTCw9x3vcSbjTGcil+Uq7Cdn7F9LytwoiUaidFnntSCiFcASKK2F9hvWndMWs/B1 mk6decCiAnOJDJFLL+1YSwbMtmpqOZZvEZ8Jc= Original-Received: by 10.229.223.136 with SMTP id ik8mr2651138qcb.92.1268074188260; Mon, 08 Mar 2010 10:49:48 -0800 (PST) In-Reply-To: <1e54fa2e1003071604w3de9e887w94c3615462935ca9@mail.gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:10039 Archived-At: --00163630eecf8a47ed04814e8791 Content-Type: text/plain; charset=ISO-8859-1 Here's a program that demonstrates the actual issue at hand. Basically, libgc finds the stack address from either glibc or the kernel, which is not what it wants because valgrind messes with the address space of the host program. This is only on Linux, but I understand the issue is similar on other BSD systems. This is the Mono file that contains some workarounds (specifically mono/metadata/boehm-gc.c:mono_gc_base_init) . Contrary to the comments in the file the issue does not appear to be thread-related, although it is solved using pthread functionality. http://anonsvn.mono-project.com/viewvc/trunk/mono/mono/metadata/boehm-gc.c?view=log The attached program grabs the stack address from the kernel, glibc, and by taking the address of a stack object, then prints the difference. When run normally, the differences are minimal, but when run under valgrind, there is a giant difference between the base of the actual program and the base given by the kernel. Ideally, this would be patched in libgc, but we'd need a way to detect whether the program is running under valgrind and the current workaround would only work for threaded versions. I'm going to take a crack at libgc CVS later on. --00163630eecf8a47ed04814e8791 Content-Type: text/x-csrc; charset=US-ASCII; name="demo.c" Content-Disposition: attachment; filename="demo.c" Content-Transfer-Encoding: base64 X-Attachment-Id: f_g6jma8q40 LyogZGVtbyB2YWxncmluZCBwcm9ncmFtOiBjYyAtbyBkZW1vIGRlbW8uYyAqLwoKI2luY2x1ZGUg PGFzc2VydC5oPgojaW5jbHVkZSA8c3RkZGVmLmg+CiNpbmNsdWRlIDxzdGRpby5oPgojaW5jbHVk ZSA8c3lzL3R5cGVzLmg+CiNpbmNsdWRlIDxzeXMvc3RhdC5oPgojaW5jbHVkZSA8ZmNudGwuaD4K CiNkZWZpbmUgU1RBVF9CVUZGRVJfU0laRSA0MDk2CiNkZWZpbmUgU1RBVF9TS0lQIDI3CgpleHRl cm4gcHRyZGlmZl90IF9fbGliY19zdGFja19lbmQ7CgppbnQgbWFpbih2b2lkKSB7CiAgaW50IGR1 bW15OwogIAogIC8qIGxpZnRlZCBmcm9tIG9zX2RlcC5jIGluIGxpYmdjICovCiAgY2hhciBzdGF0 X2J1ZltTVEFUX0JV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