[comp.unix.ultrix] brk

mcm@rti.rti.org (Mike Mitchell) (04/13/90)

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);
}
-------------------------------------------------------------------------------

joel@decwrl.dec.com (Joel McCormack) (04/14/90)

The brk() function is not fixed in any Ultrix 3.1 release that I know
of.  Even 3.1d reports that the brk function is broken.

It does appear to be fixed on Ultrix 4.0.  Thanks for making such an
easy program to verify this information.

- Joel McCormack (decwrl!joel, joel@decwrl.dec.com)

D. Allen [CGL]) (04/14/90)

I ran your test on some machines here.

DECsystem 5400, Ultrix 3.1C:
VAX8600, 4.3 BSD:

    Your brk routine is broken!

SparcServer:
Sequent:
MIPS:

    Your brk routine works correctly.
-- 
-IAN! (Ian! D. Allen) idallen@watcgl.uwaterloo.ca idallen@watcgl.waterloo.edu
 [129.97.128.64]  Computer Graphics Lab/University of Waterloo/Ontario/Canada