public inbox for linux-8086@vger.kernel.org
 help / color / mirror / Atom feed
From: Harry Kalogirou <harkal@gmx.net>
To: Linux-8086 <linux-8086@vger.kernel.org>
Subject: bug with vfork, execv
Date: 01 Nov 2002 22:19:21 +0200	[thread overview]
Message-ID: <1036181894.16096.60.camel@cool> (raw)

Hi all,
 now that the kernel supports a growing stack I was able to observe an
bug concering vfork and the way libc finds the current heap ending
point(brk).

Suppose that the shell has its t_endbrk at 0x3000. Libc also keeps this
value in a variable, and that variable is in sync with the kernel. Then
it executes a vfork() (parent waits and shares code and data with the
child) and the child calles execv(). In execv() the sbrk() is called to
enlarge the heap by 0x10 for example. sbrk() calles sys_brk() to enlarge
the heap(now the child has a t_endbrk of 0x3010) and also updates the
current brk position in the variable(the variable now also is 0x3010).
The problem is that this variable is shared with the parent, so the next
time the shell will vfork and execv again will request further memory
since the brk variable is 0x3010 now. So after every vfork-exec the
shell will request for 0x10 bytes more.

The solutions I see are :

1) Remove vfork() and make it just a fork().
2) Change the way sbrk() works in the libc, probably by changing it to  
request the current brk position from the kernel.

I would like to hear your opinions.

Harry




             reply	other threads:[~2002-11-01 20:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-01 20:19 Harry Kalogirou [this message]
2002-11-01 22:26 ` bug with vfork, execv Harry Kalogirou

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=1036181894.16096.60.camel@cool \
    --to=harkal@gmx.net \
    --cc=linux-8086@vger.kernel.org \
    /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