Subject: port-i386/1974: Large static structures cause program to segmentation fault upon execution
To: None <gnats-bugs@gnats.netbsd.org>
From: milton <Milton.Ngan@sans.vuw.ac.nz>
List: netbsd-bugs
Date: 01/25/1996 09:20:39
>Number:         1974
>Category:       port-i386
>Synopsis:       Large static structures cause program to segmentation fault upon execution
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 24 15:50:05 1996
>Last-Modified:
>Originator:     milton
>Organization:
Student Access Network System, Victoria University of Wellington

>Release:        1.1
>Environment:
	
System: NetBSD tao.sans.vuw.ac.nz 1.1 NetBSD 1.1 (TAO) #1: Mon Jan 8 13:26:40 NZDT 1996 root@pauhou.its.vuw.ac.nz:/home/its/milton/src/sys/arch/i386/compile/TAO i386


>Description:
	Declaring and instance of a large strucuture in the main program
	causes the program to segmentation fault before the program
	gets properly underway. The problem can also be reproduced under 
	NetBSD v1.0.

>How-To-Repeat:
	The following code when compiled should reproduce the fault.

#include <stdio.h>

#define BAD_NODE_ID (-1)
#define MAX_NODE 256

typedef struct Graph {
  int nodes;
  int edges;
  int node[MAX_NODE];
  int edge[MAX_NODE][MAX_NODE];
  void *node_label[MAX_NODE];
  void *edge_label[MAX_NODE][MAX_NODE];
} Graph;

int main() {
  Graph g;
  int i, j;

  for (i = 0; i < MAX_NODE; i++) {
    g.node[i] = BAD_NODE_ID;
    g.node_label[i] = NULL;
    for (j = 0; j < MAX_NODE; j++) {
      g.edge[i][j] = 0;
      g.edge_label[i][j] = NULL;
    }
  }
  g.nodes = 0;
  g.edges = 0;
  return 0;
}

>Fix:
	Unknown
>Audit-Trail:
>Unformatted: