From owner-freebsd-hackers@FreeBSD.ORG Fri May 16 19:14:17 2008 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 07167106566B for ; Fri, 16 May 2008 19:14:17 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (unknown [IPv6:2a01:170:102f::2]) by mx1.freebsd.org (Postfix) with ESMTP id 703238FC12 for ; Fri, 16 May 2008 19:14:16 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (localhost [127.0.0.1]) by lurza.secnetix.de (8.14.1/8.14.1) with ESMTP id m4GJEDt0053922; Fri, 16 May 2008 21:14:14 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.14.1/8.14.1/Submit) id m4GJEBSD053921; Fri, 16 May 2008 21:14:11 +0200 (CEST) (envelope-from olli) Date: Fri, 16 May 2008 21:14:11 +0200 (CEST) Message-Id: <200805161914.m4GJEBSD053921@lurza.secnetix.de> From: Oliver Fromme To: freebsd-hackers@FreeBSD.ORG, deathjestr@gmail.com, jille@quis.cx In-Reply-To: <44b564930805160955r76d6861fo1949c7f4d5b71ca5@mail.gmail.com> X-Newsgroups: list.freebsd-hackers User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (FreeBSD/6.2-STABLE-20070808 (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Fri, 16 May 2008 21:14:15 +0200 (CEST) Cc: Subject: Re: Trying (not) to crash with libpthread (6.3-RELEASE) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-hackers@FreeBSD.ORG, deathjestr@gmail.com, jille@quis.cx List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 May 2008 19:14:17 -0000 Mike wrote: > Jille Timmermans wrote: > > void > > sigcatcher(int sig) { > > printf("[%p] signal %d\n", pthread_self(), sig); > > printf("Test (probably) succeeded\n"); > > fflush(NULL); > > success=1; > > exit(0); > > } > > Take a look at the man page for sigaction(2). Here's an excerpt: > > "All functions not in the above lists are considered to be unsafe with > respect to signals. That is to say, the behaviour of such functions when > called from a signal handler is undefined. In general though, signal > handlers should do little more than set a flag; most other actions are > not safe." Additionally, the "success" variable should be declared as "volatile sig_atomic_t". By the way, this code ... > > char *x=malloc(1); > > [...] > > x[666]=0; .. does not necessarily cause a SIGSEGV. It may do so, but it is not guaranteed. It may as well write into a random memory area that happens to belong to your process, too. The result is undefined, i.e. it could be anything. If you need to send a SIGSEGV to yourself reliably, the best way is to kill(getpid(), SIGSEGV). Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M. Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung: secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün- chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd "File names are infinite in length, where infinity is set to 255 characters." -- Peter Collinson, "The Unix File System"