Date: Wed, 30 Jun 2010 19:23:50 -0400 From: Alexander Kabaev <kabaev@gmail.com> To: Garrett Cooper <yanefbsd@gmail.com> Cc: "Sam Fourman Jr." <sfourman@gmail.com>, Kostik Belousov <kostikbel@gmail.com>, freebsd-hackers@freebsd.org Subject: Re: kernel patch needed for wine? Message-ID: <20100630192350.105e8303@kan.dnsalias.net> In-Reply-To: <AANLkTiksgnem7qiGzpJIVQp7Dxsu0dfasF10STzSwxBf@mail.gmail.com> References: <AANLkTik5Owwpk5O6eUbSKgHxpjvcEXwilGECgtX0hx5a@mail.gmail.com> <20100630105027.GJ13238@deviant.kiev.zoral.com.ua> <AANLkTikDxVGpc6LfYlqFZLo-QiJFr8lbj2MVZMUci-lI@mail.gmail.com> <AANLkTilusilVimfscZdj3QAOOFYs3Gh3pt5V6SXe3VHP@mail.gmail.com> <AANLkTinNMaMH_5TSUL8PN1D0J-IBjIZV8K_sBTeB1H64@mail.gmail.com> <AANLkTiksgnem7qiGzpJIVQp7Dxsu0dfasF10STzSwxBf@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--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 <yanefbsd@gmail.com> wrote: > On Wed, Jun 30, 2010 at 2:22 PM, Sam Fourman Jr. <sfourman@gmail.com> > wrote: > > On Wed, Jun 30, 2010 at 11:26 AM, Garrett Cooper > > <yanefbsd@gmail.com> wrote: > >> On Wed, Jun 30, 2010 at 8:43 AM, Sam Fourman Jr. > >> <sfourman@gmail.com> 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 <stdio.h> > > #include <signal.h> > > > > > > > > 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 <err.h> > #include <signal.h> > #include <stdio.h> >=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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100630192350.105e8303>