[Bug 1779583] Re: cron do_command.c attempts a fork() without testing for errors

2018-08-28 Thread Launchpad Bug Tracker
Status changed to 'Confirmed' because the bug affects multiple users.

** Changed in: cron (Ubuntu)
   Status: New => Confirmed

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1779583

Title:
  cron do_command.c attempts a fork() without testing for errors

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cron/+bug/1779583/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1779583] Re: cron do_command.c attempts a fork() without testing for errors

2018-07-02 Thread Alexis Wilke
** Tags removed: trusty
** Tags added: xenial

** Description changed:

  The do_command.c file calls fork() twice.
  
  For the first fork(), the possibility for an error is checked properly
  and an error emitted (see
  https://bugs.launchpad.net/ubuntu/+source/cron/+bug/1702785 for an
  example when that happens: message is "can't fork".) This first fork()
  makes use of a switch() statement as expected.
  
  The second fork(), however, is used inside an if() statement like this:
  
  if (*input_data && fork() == 0) { ... }
  
  Here we can see a couple of problems. After the if block, we have this
  statement:
  
  children++;
  
  which means that we will have to wait on TWO children. However, (1) the
  *input_data could return false and thus the second child may not be
  created at all. (2) the fork() could return -1 meaning that no other
  child is created.
  
  I suppose that the child_process() probably always or nearly always has
  some input_data. Otherwise it would block waiting for a child that was
  never started. And of course, it is relatively rare that fork() fails,
  unless you are running our of RAM (heap or stack can't be allocated) or
  process space (too many processes running concurrently.)
  
  I have a proposed patch to fix the problem. It uses a switch() which
  emits an error in case the fork() fails, but let the program go on as
  before (instead of an immediate exit as in the first fork()).
  
  The children variable gets incremented only when the fork() happens and
  succeeds (default: block in the new switch().)
  
- The do_command.c file did not change between 16.04 (trusty) and 18.04
+ The do_command.c file did not change between 16.04 (xenial) and 18.04
  (bionic beaver), so the patch will work for either version.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1779583

Title:
  cron do_command.c attempts a fork() without testing for errors

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cron/+bug/1779583/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1779583] Re: cron do_command.c attempts a fork() without testing for errors

2018-07-02 Thread Brian Murray
** Tags added: cosmic

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1779583

Title:
  cron do_command.c attempts a fork() without testing for errors

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cron/+bug/1779583/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1779583] Re: cron do_command.c attempts a fork() without testing for errors

2018-07-01 Thread Ubuntu Foundations Team Bug Bot
The attachment "Compiling fix to second fork() in child_process()" seems
to be a patch.  If it isn't, please remove the "patch" flag from the
attachment, remove the "patch" tag, and if you are a member of the
~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by
~brian-murray, for any issues please contact him.]

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1779583

Title:
  cron do_command.c attempts a fork() without testing for errors

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cron/+bug/1779583/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1779583] Re: cron do_command.c attempts a fork() without testing for errors

2018-07-01 Thread Alexis Wilke
I guess I should attempt to compile before submitting a patch. Some
brackets were required in one of the cases.

** Patch added: "Compiling fix to second fork() in child_process()"
   
https://bugs.launchpad.net/ubuntu/+source/cron/+bug/1779583/+attachment/5158458/+files/do_command-2.patch

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1779583

Title:
  cron do_command.c attempts a fork() without testing for errors

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cron/+bug/1779583/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1779583] Re: cron do_command.c attempts a fork() without testing for errors

2018-07-01 Thread Alexis Wilke
** Description changed:

  The do_command.c file calls fork() twice.
  
- For the first for(), the possibility for an error is checked properly
+ For the first fork(), the possibility for an error is checked properly
  and an error emitted (see
  https://bugs.launchpad.net/ubuntu/+source/cron/+bug/1702785 for an
  example when that happens: message is "can't fork".) This first fork()
  makes use of a switch() statement as expected.
  
  The second fork(), however, is used inside an if() statement like this:
  
  if (*input_data && fork() == 0) { ... }
  
  Here we can see a couple of problems. After the if block, we have this
  statement:
  
  children++;
  
  which means that we will have to wait on TWO children. However, (1) the
  *input_data could return false and thus the second child may not be
  created at all. (2) the fork() could return -1 meaning that no other
  child is created.
  
  I suppose that the child_process() probably always or nearly always has
  some input_data. Otherwise it would block waiting for a child that was
  never started. And of course, it is relatively rare that fork() fails,
  unless you are running our of RAM (heap or stack can't be allocated) or
  process space (too many processes running concurrently.)
  
  I have a proposed patch to fix the problem. It uses a switch() which
  emits an error in case the fork() fails, but let the program go on as
  before (instead of an immediate exit as in the first fork()).
  
  The children variable gets incremented only when the fork() happens and
  succeeds (default: block in the new switch().)
  
  The do_command.c file did not change between 16.04 (trusty) and 18.04
  (bionic beaver), so the patch will work for either version.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1779583

Title:
  cron do_command.c attempts a fork() without testing for errors

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cron/+bug/1779583/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

[Bug 1779583] Re: cron do_command.c attempts a fork() without testing for errors

2018-07-01 Thread Alexis Wilke
This may be one solution to the problem reported here:

https://bugs.launchpad.net/ubuntu/+source/cron/+bug/1702785

Because when the second fork() fails, the cron process waits for 2
children, one of which doesn't even exist and thus cron is stuck with "a
ton" of memory allocated. This would also happen if *input_data is
false. So not just because the fork() fails... but it could be because
it does not even happen.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1779583

Title:
  cron do_command.c attempts a fork() without testing for errors

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cron/+bug/1779583/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs