All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: <jb1@btstream.com>
To: Harry Kalogirou <harkal@gmx.net>
Cc: Linux-8086 <linux-8086@vger.kernel.org>
Subject: fork bug [WAS: Re: "mount" bug]
Date: Sun, 27 Oct 2002 04:57:44 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.33.0210270416350.5872-100000@olympus.btstream.com> (raw)
In-Reply-To: <1035642211.5492.41.camel@cool>

On 26 Oct 2002, Harry Kalogirou wrote:

> "Cannot fork" is emmited by the shell, when the fork() system call
> fails. The system call will fail :
> 
> 1) If there are no more process slots available.
> 2) There is not enough free memory.
> 
> What exacly happend there, I realy can't tell. The only thing I can tell
> is that something "very" bad happed there. I personaly havedn't seen
> ELKS behave like that before. 

There appears to be a bug in the "get_pid()" function from fork.c. The 
code fragment:
    if (++last_pid == 32768)
        last_pid = 1;
must eventually fail because last_pid is declared as type pid_t, which is 
typedef'ed as __s16, which is in turn typedef'ed as signed short int. 
Since signed 16-bit numbers roll over from 32767 to negative numbers, they 
can never equal 32768. A possible fix might be:
    if ( (++last_pid && 0x7fff) == 0 )
        last_pid = 1;
or, perhaps smaller and faster:
    if !( (last_pid++) &= 0x7fff )
        last_pid++;
The latter may have superfluous parentheses because I'm not sure of the 
precedence, and whether "variable++" is smaller and faster than 
"++variable" is probably compiler-dependent.


  reply	other threads:[~2002-10-27 12:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-25  9:28 "mount" bug jb1
2002-10-25 13:30 ` Harry Kalogirou
2002-10-26  8:55   ` jb1
2002-10-26 14:49     ` Harry Kalogirou
2002-10-27 12:57       ` jb1 [this message]
2002-10-27 19:49         ` fork bug [WAS: Re: "mount" bug] 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=Pine.LNX.4.33.0210270416350.5872-100000@olympus.btstream.com \
    --to=jb1@btstream.com \
    --cc=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 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.