Subject: Re: dynamic linker/loader problem
To: Rafal Boni <rafal@attbi.com>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-toolchain
Date: 03/27/2003 21:31:21
--k+w/mQv8wyuph6w0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Thu, Mar 27, 2003 at 12:52:02PM -0500, Rafal Boni wrote:
> As Christos suggested, writing a simple program that uses termcap and
> also implements it's own malloc/free (mmm, reimplementing malloc/free
> with realloc... Almost worthy of libmem v2 8-) triggers the bug.
> 
> Attached is a simple program that does that, and indeed has the same
> issue.

Oh, OK.
So here is another test case, which is maybe easier to debug (less libraries
involved). It uses getcwd() which calls malloc.
On a i386:
rochebonne:/home/bouyer/tst>./main 
this is my malloc
On sgimips:
islates:/home/bouyer/tst>./main 
real malloc called

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 24 ans d'experience feront toujours la difference
--

--k+w/mQv8wyuph6w0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="main.c"

#include <malloc.h>
#include <stdio.h>
#include <unistd.h>

main(int argc, char **argv)
{
	char *p;
	p = getcwd(NULL, 0);
	if (p != NULL) {
		printf("real malloc called\n");
		exit(1);
	}
	exit(1);
}

void *
malloc(size_t size) {
	char *s = "this is my malloc\n";
	write(0, s, strlen(s));
	return NULL;
}


--k+w/mQv8wyuph6w0--