brk() bug

Mike Mitchell mcm at rti.rti.org
Fri Apr 13 06:15:21 AEST 1990


I see that DEC has new versions of ULTRIX to support the new workstations.
I am wondering if ULTRIX 3.1C, ULTRIX 3.1D, or a beta-version of ULTRIX 4.0
fixes a bug I reported in August of last year.  The problem is with the way
the 'brk()' system call works.  Specifically, it does not properly free up
memory released.  This bug was fixed in BSD 4.3-tahoe, and only takes one
line of code to correct.  It does NOT show up on machines with less than
8 TLB entries, such as MicroVaxes.  All of the DECstations/DECsystems are
affected.  If you are running a version of ULTRIX more recent than 3.1A,
please try running the enclosed program.  I'd really like to know if DEC
has fixed this bug.

-------------------------------------------------------------------------------
/*
 * This program shows off a problem with the kernel's "expand()" routine.
 */
#include <signal.h>

main()
{
    char *old_break, *cp;
    int i;
    extern char *sbrk(), *brk();
    void segv();

    signal(SIGSEGV, segv);

    i = getpagesize();
    old_break = sbrk(0);		/* get the current "break" */
    (void) brk(old_break + 2*i);	/* bump it up 2 pages */

    cp = old_break + i + 256;
    *cp = 1;				/* write into a new page */

    (void) brk(old_break);		/* release the memory */

    *cp = 2;				/* write into the page again.  This */
					/* time, you should get a sigsegv */

    printf("Your brk routine is broken!\n");
    exit(1);
}

void segv()
{
    printf("Your brk routine works correctly.\n");
    exit(0);
}
-------------------------------------------------------------------------------



More information about the Comp.unix.ultrix mailing list