All of lore.kernel.org
 help / color / mirror / Atom feed
* [parisc-linux] Problem with malloc(3)/sbrk(2)/brk(2)/something
@ 2000-07-12 19:55 David Huggins-Daines
  2000-07-13 16:28 ` David Huggins-Daines
  0 siblings, 1 reply; 3+ messages in thread
From: David Huggins-Daines @ 2000-07-12 19:55 UTC (permalink / raw)
  To: parisc-linux

Hi,

This is a follow-up to my footnote about not being able to run the
'config.guess' shell script with ash (and some other stuff) on our
userland.  Basically I've found a minimal testcase for the problem,
which is that it's not possible to malloc() across a page boundary.

Beware that since we don't have a real page fault handler, this
program will crash your machine.  (Press TOC, and we'll take it from
there :-)

If you turn on debugging assertions in the malloc code you'll see that
it triggers this assertion:

  /* We always land on a page boundary */
  assert(((unsigned long)((char*)top(ar_ptr) + top_size) & (pagesz-1)) == 0);

I don't see sbrk() or brk() failing, so I'm not exactly sure why this
happens.  I suspect they are returning bogus values in this case.  If
someone knows that would be great although I expect to find the
problem soon (I may try to get strace going, since it will be very
useful for other similar problems).

#include <stdlib.h>
#include <stdio.h>

int main()
{
	/* get the first address */
	char *foo = malloc(16);

	/* now try to break a page boundary */
	char *target = (char *) ((unsigned long) (foo + 4095) & ~4095);

	size_t nbytes = target - foo;
	foo = malloc(nbytes);
	return 0;
}

-- 
dhd@linuxcare.com, http://www.linuxcare.com/
Linuxcare. Support for the revolution.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [parisc-linux] Problem with malloc(3)/sbrk(2)/brk(2)/something
  2000-07-12 19:55 [parisc-linux] Problem with malloc(3)/sbrk(2)/brk(2)/something David Huggins-Daines
@ 2000-07-13 16:28 ` David Huggins-Daines
  2000-07-13 16:48   ` David Huggins-Daines
  0 siblings, 1 reply; 3+ messages in thread
From: David Huggins-Daines @ 2000-07-13 16:28 UTC (permalink / raw)
  To: parisc-linux

David Huggins-Daines <dhd@linuxcare.com> writes:

> userland.  Basically I've found a minimal testcase for the problem,
> which is that it's not possible to malloc() across a page boundary.

Oops, sorry, this did not seem to be the actual problem.  It seems
that I may have been running a kernel that was not %r8-clean, or
something similar, because recompiling malloc.c with -ffixed-r8 made
these test cases work :(

However config.guess still doesn't work :( Once I get a working kernel
again I suppose I'll look at that.

-- 
dhd@linuxcare.com, http://www.linuxcare.com/
Linuxcare. Support for the revolution.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [parisc-linux] Problem with malloc(3)/sbrk(2)/brk(2)/something
  2000-07-13 16:28 ` David Huggins-Daines
@ 2000-07-13 16:48   ` David Huggins-Daines
  0 siblings, 0 replies; 3+ messages in thread
From: David Huggins-Daines @ 2000-07-13 16:48 UTC (permalink / raw)
  To: parisc-linux

David Huggins-Daines <dhd@linuxcare.com> writes:

> However config.guess still doesn't work :( Once I get a working kernel
> again I suppose I'll look at that.

Okay, fixed.  See parisc-linux-cvs and rebuild your kernels :-)

-- 
David Huggins-Daines - dhd@debian.org

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-07-13 16:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-07-12 19:55 [parisc-linux] Problem with malloc(3)/sbrk(2)/brk(2)/something David Huggins-Daines
2000-07-13 16:28 ` David Huggins-Daines
2000-07-13 16:48   ` David Huggins-Daines

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.