From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49874) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHi8u-0002Xd-MK for qemu-devel@nongnu.org; Thu, 05 Sep 2013 18:35:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VHi8o-0005G0-7X for qemu-devel@nongnu.org; Thu, 05 Sep 2013 18:35:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47788) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHi8n-0005Fh-VG for qemu-devel@nongnu.org; Thu, 05 Sep 2013 18:35:06 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r85MZ51U009664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 5 Sep 2013 18:35:05 -0400 Message-ID: <522907AE.7020804@redhat.com> Date: Fri, 06 Sep 2013 00:37:34 +0200 From: Laszlo Ersek MIME-Version: 1.0 References: <5824aebefdadb9beb24cda3fab0398931bedbfb1.1378383549.git.minovotn@redhat.com> <52288696.1010007@redhat.com> In-Reply-To: <52288696.1010007@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] vl.c: Implement SIGILL signal handler for triggering SIGSEGV List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michal Novotny Cc: Paolo Bonzini , qemu-devel@nongnu.org On 09/05/13 15:26, Paolo Bonzini wrote: > Il 05/09/2013 14:19, Michal Novotny ha scritto: >> This is the patch to introduce SIGILL handler to be able to trigger >> SIGSEGV signal in qemu. This has been written to help debugging >> state when qemu crashes by SIGSEGV as a simple reproducer to >> emulate such situation in case of need. > > What's wrong with "kill -11" or, within gdb, "j *0x1234"? Why do you > need a SIGILL handler for this? In fact, SIGILL is a pretty bad choice: > QEMU includes a JIT compiler, so a SIGILL is a relatively common thing > to happen while debugging it. > > Also: > > (1) there is a known bug in qemu-thread-posix.c, which should not block > SIGILL, SIGBUS, SIGSEGV, SIGFPE and SIGSYS. Without fixing that, this > trick will only work for the iothread and not for the VCPU threads. If > you can produce a patch for this, it would be very nice. > >> >> + int *p = NULL; >> + >> + *p = 0xDEADBEEF; > > (2) This is undefined behavior. You probably want something like > "volatile int *p = (volatile int *)(intptr_t)4;" instead. What's wrong with raise(SIGSEGV)? I don't understand the motivation BTW -- what sense does it make to turn SIGILL into SIGSEGV? If someone just wants to force a "coredump due to signal" interactively, SIGQUIT was invented *exactly* for that. You can even send it from the controlling terminal directly, with Ctrl-\. (More precisely, by entering QUIT character, see eg. the stty manual.) (Also, in this specific case it would be no problem if all but one threads blocked SIGQUIT -- the terminal driver or the "kill" utility would generate the signal for the entire process, not a specific thread, and then the signal would be delivered to some thread among those threads that are not blocking the signal.) Laszlo