From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30833 invoked by alias); 6 Sep 2004 12:47:50 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 30821 invoked from network); 6 Sep 2004 12:47:46 -0000 Received: from unknown (HELO sentinel2.physics.ox.ac.uk) (163.1.243.52) by sourceware.org with SMTP; 6 Sep 2004 12:47:46 -0000 Received: from eros.physics.ox.ac.uk ([163.1.247.107] helo=netra2.physics.ox.ac.uk) by sentinel2.physics.ox.ac.uk with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1C4IuM-0005tB-Bu for gcc-help@gcc.gnu.org; Mon, 06 Sep 2004 13:47:43 +0100 Received: from apollo ([163.1.247.26] helo=apollo.physics.ox.ac.uk) by netra2.physics.ox.ac.uk with esmtp (Exim 3.32 #1) id 1C4IuL-0001K5-00 for gcc-help@gcc.gnu.org; Mon, 06 Sep 2004 13:47:41 +0100 Received: from apollo.physics.ox.ac.uk (localhost [127.0.0.1]) by apollo.physics.ox.ac.uk with SMTP id i86ClfSe021725 for ; Mon, 6 Sep 2004 13:47:41 +0100 (BST) Received: from localhost (liddle@localhost) by apollo.physics.ox.ac.uk (8.12.9+Sun/8.12.9/Submit) with ESMTP id i86Cleci021722 for ; Mon, 6 Sep 2004 13:47:41 +0100 (BST) X-Authentication-Warning: apollo.physics.ox.ac.uk: liddle owned process doing -bs Date: Mon, 06 Sep 2004 12:47:00 -0000 From: Jack Liddle X-X-Sender: liddle@apollo To: gcc-help@gcc.gnu.org Subject: Why does this segfault, big struct: too big? In-Reply-To: <1094473544.413c57486f286@imp5-q.free.fr> Message-ID: References: <1094473544.413c57486f286@imp5-q.free.fr> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scan-Signature: 5ddaee6ab7e3d282e7a41188f23710de X-Sentinel-Whitelist: X-Sentinel-Score: -5.1 X-Sentinel-Report: -5.1/5.0 ---- SA results AWL,BAYES_00,OBFUSCATION_CHARACTERS autolearn=no X-SW-Source: 2004-09/txt/msg00035.txt.bz2 When I compile the following code I get a strange intermittent segfault. Compiling with gcc -lm -O -Wall mk2.c -o mk2 Case 1) Pbars = 400, final "printf" statement present -> No seg fault, GDB says exits with code 04 Case 2) Pbars = 500, final "printf" statement present -> Seg faults Program received signal SIGSEGV, Segmentation fault. 0x0804841c in main (argc=1, argv=0xbfffdc44) at 2dhistomk2.c:43 43 printf("junk"); Case 3) Pbars >= 500, final "printd" statement NOT present -> NO seg fault, GDB says exits with code 01 This fault occurs as part of a longer code, the printf statement triggers the problem as do other calls like "srand48(0)" I can't imagine why the size of a struct is important and why these statements would trigger this. Everything seems to be linked OK, with a lower value of Pbars full code does exactly what it should do. OH Yeah gcc -v, gives me Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-113) Yours very confused Jack Liddle Theoretical Physics University Of Oxford #include #include #include #include #include //Adjust these for your run #define Sbars 440 #define Smin 875 #define Smax 985 #define Pmin 0 #define Pmax 2 #define Pbars 400 #define Nblocks 20 struct histogrambar { double Sstart; double Sfinish; double Pstart; double Pfinish; double number; }; typedef struct histogrambar Histogrambar; struct histogram { struct histogrambar bar[Sbars][Pbars]; }; typedef struct histogram Histogram; int main(int argc,char **argv) { Histogram hist; printf("junk"); }