From owner-freebsd-hackers@FreeBSD.ORG Wed Jun 30 23:24:05 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DC6461065673 for ; Wed, 30 Jun 2010 23:24:05 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 7D7E38FC16 for ; Wed, 30 Jun 2010 23:24:05 +0000 (UTC) Received: by vws6 with SMTP id 6so590760vws.13 for ; Wed, 30 Jun 2010 16:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type; bh=7MxOz/Var6Xph7Y8b3qhbrCD7iT7REMBI90uDLqfskE=; b=n+Y2RfUMI3ejc7hsGE8G+9fKoEc8NWdHQ2UyJUd4F+HWVyQm85LUszRWVbPktLacrD rpl3icBDXM+opnhF5t+QmMhsyOJCiVFxwKH2vn5b7Emd9RR6bh/rpltLUalGO8tWRtQz a9vm8YBFQllUcnMwKSdPkLlYHLADtdg7+/es8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type; b=DnJ9yxdbZiJ5DkRQO2jJnHoAiPUybTkbWz3sk7DTaXtrAz4kYxn5GqwB0F2OEblooP O7jWpMEl5jWy/d7JZhZOvyrKf0G5RB58XwXX6gP6csTExXbfMhkzLoAOtdKUY15eHWu7 6GJPWvodZiyoVP2oJvl+rSGnkldykf1ZtK4RI= Received: by 10.229.96.209 with SMTP id i17mr5561952qcn.293.1277940237553; Wed, 30 Jun 2010 16:23:57 -0700 (PDT) Received: from kan.dnsalias.net (c-24-63-226-98.hsd1.ma.comcast.net [24.63.226.98]) by mx.google.com with ESMTPS id t34sm47873907qcp.42.2010.06.30.16.23.56 (version=SSLv3 cipher=RC4-MD5); Wed, 30 Jun 2010 16:23:56 -0700 (PDT) Date: Wed, 30 Jun 2010 19:23:50 -0400 From: Alexander Kabaev To: Garrett Cooper Message-ID: <20100630192350.105e8303@kan.dnsalias.net> In-Reply-To: References: <20100630105027.GJ13238@deviant.kiev.zoral.com.ua> X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; amd64-portbld-freebsd9.0) Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/gPDZ6W8c_eB4jEADn4G1kSm"; protocol="application/pgp-signature" Cc: "Sam Fourman Jr." , Kostik Belousov , freebsd-hackers@freebsd.org Subject: Re: kernel patch needed for wine? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jun 2010 23:24:05 -0000 --Sig_/gPDZ6W8c_eB4jEADn4G1kSm Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: quoted-printable On Wed, 30 Jun 2010 14:42:47 -0700 Garrett Cooper wrote: > On Wed, Jun 30, 2010 at 2:22 PM, Sam Fourman Jr. > wrote: > > On Wed, Jun 30, 2010 at 11:26 AM, Garrett Cooper > > wrote: > >> On Wed, Jun 30, 2010 at 8:43 AM, Sam Fourman Jr. > >> wrote: > >>>> Which patch ? icebp generates the SIGTRAP on latest 8-stable, > >>>> verified by the following trivival assembler program: > >>>> =9A =9A =9A =9A.text > >>>> =9A =9A =9A =9A.globl =9Amain > >>>> main: > >>>> =9A =9A =9A =9A.byte =9A 0xf1 > >>>> =9A =9A =9A =9Axorl =9A =9A%edi,%edi > >>>> =9A =9A =9A =9Acall =9A =9Aexit > >>>> > >>> > > > > Here is the C program that the linux people used as a test case. > > > > *************************************************************** > > #include > > #include > > > > > > > > void trap_handler(int sig) > > { > > =9A =9A =9A =9Aprintf("trapped\n"); > > } > > > > > > /* > > =9A* icebp > > =9A* ret > > =9A*/ > > char icebp_func[] =3D "\xf1\xc3"; > > typedef void (*icebp_call)(void); > > > > int main(int argc, char **argv) > > { > > =9A =9A =9A =9Aicebp_call func =3D (icebp_call)icebp_func; > > > > =9A =9A =9A =9Asignal(SIGTRAP, trap_handler); > > > > =9A =9A =9A =9Afunc(); > > > > =9A =9A =9A =9Areturn 0; > > } > > > > *************************************************************** > > > > My question is why doe the above code not print trapped on amd64? > > > > FreeBSD 8.1 i386 this code prints "Trapped" as intended > > FreeBSD 8.1 amd64 this code prints "Segmentation fault: 11" > > FreeBSD 8.1 amd64 chrooted to 32bit prints "Segmentation fault" > > > > I did verify that from Linux amd64 this works and prints "Trapped" > > uname -a > > Linux workstation 2.6.32-23-generic #37-Ubuntu SMP Fri Jun 11 > > 08:03:28 UTC 2010 x86_64 GNU/Linux >=20 > Hmmm... I've seen similar whackiness with Linux and signals, but > that's a different thing entirely (it was rt signals vs non-rt > signals). >=20 > Here's a modified version of the testcase (wanted to make sure that > things were sane): >=20 > $ cat test_sigtrap.c > #include > #include > #include >=20 > int trapped =3D 0; >=20 > void trap_handler(int sig) > { > trapped =3D 1; > } >=20 >=20 > /* > * icebp > * ret > */ > char icebp_func[] =3D "\xf1\xc3"; > typedef void (*icebp_call)(void); >=20 > int main(int argc, char **argv) > { > icebp_call func =3D (icebp_call)icebp_func; >=20 > if (signal(SIGTRAP, trap_handler) =3D=3D SIG_ERR) > err(1, "signal"); >=20 > func(); >=20 > if (trapped) > printf("Admiral Ackbar: it's a trap!\n"); >=20 > return 0; > } >=20 > Ran it and it segfaulted on CURRENT: >=20 Now make icebp_func const and observe the program start working. The test case is broken as written, because icebp_func array is writable, so in ends up in a non-const part of .bss, which is not marked as executable and rightfully causes SIGSEGV when jumped to.=20 --=20 Alexander Kabaev --Sig_/gPDZ6W8c_eB4jEADn4G1kSm Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.15 (FreeBSD) iD8DBQFMK9ILQ6z1jMm+XZYRAkTVAJ9p5UCJ3eXjCUcLR6qiLy2ilZ5JxgCgiPI6 691v+Jos2VTst3WIQcvHLu8= =vGhJ -----END PGP SIGNATURE----- --Sig_/gPDZ6W8c_eB4jEADn4G1kSm--