From owner-freebsd-stable Tue Mar 18 12:24: 2 2003 Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C258137B401 for ; Tue, 18 Mar 2003 12:23:58 -0800 (PST) Received: from bremen.shuttle.de (bremen.shuttle.de [194.95.249.251]) by mx1.FreeBSD.org (Postfix) with ESMTP id 19BC243F75 for ; Tue, 18 Mar 2003 12:23:55 -0800 (PST) (envelope-from schweikh@schweikhardt.net) Received: from bremen.shuttle.de (localhost [127.0.0.1]) by bremen.shuttle.de (Postfix) with ESMTP id DC12617D99 for ; Tue, 18 Mar 2003 21:23:52 +0100 (CET) Received: (from uucp@localhost) by bremen.shuttle.de (8.12.3/8.12.3/Debian-5) with UUCP id h2IKNqR0001007 for stable@freebsd.org; Tue, 18 Mar 2003 21:23:52 +0100 Received: from hal9000.schweikhardt.net (localhost [127.0.0.1]) by hal9000.schweikhardt.net (8.12.8/8.12.8) with ESMTP id h2IKOqGX003277 for ; Tue, 18 Mar 2003 21:24:52 +0100 (CET) (envelope-from schweikh@hal9000.schweikhardt.net) Received: (from schweikh@localhost) by hal9000.schweikhardt.net (8.12.8/8.12.6/Submit) id h2IKOqGu003276 for stable@freebsd.org; Tue, 18 Mar 2003 21:24:52 +0100 (CET) Date: Tue, 18 Mar 2003 21:24:52 +0100 From: Jens Schweikhardt To: stable@freebsd.org Subject: stack overflow detection broken Message-ID: <20030318202452.GA2886@schweikhardt.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG hello, world\n the port lang/ocaml does not configure anymore on 4.8-STABLE/RC (It configures fine on 4.7-RELEASE, however, so this is why I think we may have a regression; see also http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/45233). During configuration it runs the test C program stackov.c appended below. Compile with $ cc -o tst -DTARGET_i386 -DSYS_bsd_elf stackov.c -pthread and run with $ ./tst This program never terminates, hogs the CPU, and is unkillable with TERM, INT, HUP or QUIT. kill -KILL will terminate it of course. If one drops the -pthread the program runs to completion without any obvious problems. My question is: Is stackov.c doing something nasty that can not be expected to work or is FreeBSD doing something wrong when the pthreads are used? Regards, Jens -- Jens Schweikhardt http://www.schweikhardt.net/ SIGSIG -- signature too long (core dumped) /***********************************************************************/ /* */ /* Objective Caml */ /* */ /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ /* */ /* Copyright 2001 Institut National de Recherche en Informatique et */ /* en Automatique. All rights reserved. This file is distributed */ /* under the terms of the GNU Library General Public License, with */ /* the special exception on linking described in file ../../LICENSE. */ /* */ /***********************************************************************/ /* $Id: stackov.c,v 1.3 2001/12/07 13:39:44 xleroy Exp $ */ #include #include #include static char sig_alt_stack[SIGSTKSZ]; static char * system_stack_top; #if defined(TARGET_i386) && defined(SYS_linux_elf) static void segv_handler(int signo, struct sigcontext sc) { char * fault_addr = (char *) sc.cr2; #else static void segv_handler(int signo, siginfo_t * info, void * context) { char * fault_addr = (char *) info->si_addr; #endif struct rlimit limit; if (getrlimit(RLIMIT_STACK, &limit) == 0 && ((long) fault_addr & (sizeof(long) - 1)) == 0 && fault_addr < system_stack_top && fault_addr >= system_stack_top - limit.rlim_cur - 0x2000) { _exit(0); } else { _exit(4); } } void f(char * c); void g(char * c) { char d[1024]; f(d); } void f(char * c) { char d[1024]; g(d); } int main(int argc, char ** argv) { struct sigaltstack stk; struct sigaction act; struct rlimit limit; stk.ss_sp = sig_alt_stack; stk.ss_size = SIGSTKSZ; stk.ss_flags = 0; #if defined(TARGET_i386) && defined(SYS_linux_elf) act.sa_handler = (void (*)(int)) segv_handler; act.sa_flags = SA_ONSTACK | SA_NODEFER; #else act.sa_sigaction = segv_handler; act.sa_flags = SA_SIGINFO | SA_ONSTACK | SA_NODEFER; #endif sigemptyset(&act.sa_mask); system_stack_top = (char *) &act; limit.rlim_max = limit.rlim_cur = 0x20000; if (sigaltstack(&stk, NULL) != 0) { perror("sigaltstack"); return 2; } if (sigaction(SIGSEGV, &act, NULL) != 0) { perror("sigaction"); return 2; } if (setrlimit(RLIMIT_STACK, &limit) != 0) { perror("setrlimit"); return 2; } f(NULL); return 2; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message