From: David Huggins-Daines <dhd@linuxcare.com>
To: parisc-linux@thepuffingroup.com
Subject: [parisc-linux] Problem with malloc(3)/sbrk(2)/brk(2)/something
Date: 12 Jul 2000 15:55:47 -0400 [thread overview]
Message-ID: <8766qb86nw.fsf@linuxcare.com> (raw)
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.
next reply other threads:[~2000-07-12 19:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-07-12 19:55 David Huggins-Daines [this message]
2000-07-13 16:28 ` [parisc-linux] Problem with malloc(3)/sbrk(2)/brk(2)/something David Huggins-Daines
2000-07-13 16:48 ` David Huggins-Daines
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8766qb86nw.fsf@linuxcare.com \
--to=dhd@linuxcare.com \
--cc=parisc-linux@thepuffingroup.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox