From owner-freebsd-hackers@FreeBSD.ORG Thu Apr 24 06:19:33 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2FAD2124; Thu, 24 Apr 2014 06:19:33 +0000 (UTC) Received: from mx0.deglitch.com (unknown [IPv6:2001:16d8:ff00:19d::2]) by mx1.freebsd.org (Postfix) with ESMTP id D9F831B05; Thu, 24 Apr 2014 06:19:32 +0000 (UTC) Received: from [192.168.11.7] (unknown [98.234.106.231]) by mx0.deglitch.com (Postfix) with ESMTPSA id C19208FC27; Thu, 24 Apr 2014 10:19:04 +0400 (MSK) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Subject: Re: valgrind on amd64 crashes when delivering signal for threaded application From: Stanislav Sedov In-Reply-To: <20140423200135.GA6009@gmail.com> Date: Wed, 23 Apr 2014 23:18:57 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <5FDC5FC6-8748-494C-982B-0CEF734BD883@freebsd.org> References: <20140423200135.GA6009@gmail.com> To: Mikolaj Golub X-Mailer: Apple Mail (2.1874) Cc: freebsd-hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Apr 2014 06:19:33 -0000 On Apr 23, 2014, at 1:01 PM, Mikolaj Golub wrote: > --- coregrind/m_sigframe/sigframe-amd64-freebsd.c.orig 2014-04-23 = 22:39:45.000000000 +0300 > +++ coregrind/m_sigframe/sigframe-amd64-freebsd.c 2014-04-23 = 22:40:23.000000000 +0300 > @@ -250,7 +250,7 @@ static Addr build_sigframe(ThreadState * > UWord err; >=20 > rsp -=3D sizeof(*frame); > - rsp =3D VG_ROUNDDN(rsp, 16); > + rsp =3D VG_ROUNDDN(rsp, 16) - 8; > frame =3D (struct sigframe *)rsp; >=20 > if (!extend(tst, rsp, sizeof(*frame))) >=20 > Unfortunately, I have poor understanding of valgrind internals and > what is going on exactly when it delivers a signal to the process, so > failed to find a proper fix. This sounds like a proper solution to me though. Stack handling in = valgrind is indeed convoluted, but it seems in this case it clearly misaligns the = stack as it does not take into account the return address. Any objections if = I commit this fix to valgrind-freebsd? Thanks a lot for tracking this! -- ST4096-RIPE