[comp.os.minix] Is this a MacMinix bug, or is it my machine only?

paul@ukpoit.co.uk (Paul Wood) (06/28/91)

I have been testing the recently posted uucp and I am getting problems
with the uucico. The problems are really puzzelling. Can some MacMinix
user please try out the following test code based upon a section of
uucico and tell me if it works or fails.

main() {
	char *memory;

	if((memory=(char *)malloc(15)) == (char *)0) {
		printf("malloc failed\n");
	}
	else {
		free(memory);
		printf("memory freed\n");
	}
	printf("test complete\n");
}

The free fails on my MacMinix with the message 
    "assert failed in lib/malloc.c"

It works on my Unix machines, which of course is should!



-- 
Paul Wood                  [ e-mail: paul@ukpoit.co.uk or ...!ukc!ukpoit!paul ]
                    [ address: iT, Barker Lane, Chesterfield, England S40 1DY ]
            [ phone: +44 246 214256, postline: 5403 4256, fax: +44 246 214353 ]

ralf@ptavv.ka.sub.org (Ralf Wenk) (06/30/91)

In article <1991Jun28.084706.12180@ukpoit.co.uk> paul@ukpoit.co.uk (Paul Wood)
writes:
> I have been testing the recently posted uucp and I am getting problems
> with the uucico. The problems are really puzzelling. Can some MacMinix
> user please try out the following test code based upon a section of
> uucico and tell me if it works or fails.
> 
> main() {
> 	char *memory;
> 
> 	if((memory=(char *)malloc(15)) == (char *)0) {
> 		printf("malloc failed\n");
> 	}
> 	else {
> 		free(memory);
> 		printf("memory freed\n");
> 	}
> 	printf("test complete\n");
> }
> 
> The free fails on my MacMinix with the message 
>     "assert failed in lib/malloc.c"

Same problem in MINIX ST with this source. The address passed to free(3)
is garbage.

You are assuming sizeof(int) == sizeof(void *) which is not true in Mac
and ST (AMIGA ?) but in PC MINIX. Look at the assembler output of the
ACK compiler and you will see why the result is damaged. If you add
exterm void *malloc();
or better
#include <stdlib.h>
it will work.

> 
> It works on my Unix machines, which of course is should!

Because the sizes are equal for your C compiler.

-- 
-- 
Ralf Wenk -- ralf@ptavv.ka.sub.org