Subject: kernel bug in NetBSD/Amiga? Help!
To: None <Amiga@NetBSD.ORG>
From: Jake Hamby <>
List: amiga
Date: 12/16/1995 01:59:08
I've still been having trouble trying to compile GCC 2.7.2 with 
NetBSD/Amiga due to what I am now certain is a subtle VM problem with the 
Amiga kernel!  Please take the time to test this simple program on your 
system and report to me (no need to copy to the NetBSD list) whether or 
not it crashes).  Beware that it will eat up a certain amount of swap 
space, 16MB should be adequate.  Thanks!

This test program which will reliably segfault with i=174687, which
you can verify with gdb on the core.  It creates 500,000 nodes in a chain,
then traverses the chain, then recursively traverses the chain and frees
the nodes in reverse order (it is when traversing the second time,
searching for the end node, that it segfaults).  Considering the large
number of nodes, it should give a good workout to the VM subsystem as well
as malloc/free/sbrk.  It consistently crashes on my NetBSD/Amiga system.

     Jake Hamby                         |   E-Mail:
  Student, Cal Poly University, Pomona  |   System Administrator, JPL

#include <stdio.h>

struct node {
    char *text;
    struct node *next;

void freenode(struct node *n);

int i;

main() {
    struct node *n, *n1;

    n = (struct node *)malloc(sizeof(struct node));
    n1 = n;
    for(i=0; i<500000; i++) {
	n1->next = (struct node *)malloc(sizeof(struct node));
	n1 = n1->next;
    n1->next = NULL;  /* Last node */

    n1 = n;
    for(i=0; i<500000; i++) {  /* Traverse nodes for no reason */
	n1 = n1->next;

    freenode(n);	/* Recursively free nodes */
    return 0;

void freenode(struct node *n) {
    i++;		/* When NetBSD/Amiga segfaults, check this value */