public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org
Subject: Re: system and popen fail in case of big application
Date: Tue, 11 Sep 2018 20:16:00 -0000	[thread overview]
Message-ID: <0caab9ea-5c2c-fe37-385b-090b21dd3cbb@linaro.org> (raw)
In-Reply-To: <CAKCAbMgVg8RyKeEZi40EL2CG=V859RYS541YGMHS4dyTp_mVWg@mail.gmail.com>



On 09/09/2018 19:44, Zack Weinberg wrote:
> On Sun, Sep 9, 2018 at 6:16 PM Sergey Melnikov
> <melnikov.sergey.v@gmail.com> wrote:
>>
>> Hi all,
>>
>> I'm developing JNI code for a Java application. My code works fine in
>> case of small heap size. Nevertheless, if I set heap size to something
>> reasonably big (like 20Gb on my dev PC with 32Gb of RAM), 'popen' and
>> 'system' glibc calls don't work with ENOMEM errno.
>>
>> So, my question is if does it worth to rewrite existing popen/system
>> calls with posix_spawn as StackOverflow recommends? If so, I may
>> implement and contribute this to glibc.
> 
> What would be worthwhile is to change popen and system so that they
> internally use *vfork*, on systems where vfork is not the same as
> fork. posix_spawn is just an elaborate and inconvenient wrapper around
> vfork, and I don't think we should be using it internally or
> encouraging its use by others.  Also, unlike vfork, it does not
> guarantee to avoid the problem you are experiencing.

We changed posix_spawn to exactly avoid call vfork due its inherent usage
issue with signal handlers (BZ#14750), cancellation state being shared 
with the parent (BZ#10354), and the vfork limitation of possible parent 
clobber due stack spilling (which would require some specific compiler
support to mark the call).  

I can't really see why you think not using posix_spawn, which addresses
all this issues, would be better to either user a problematic interface
(vfork) or replicate the logic all over arch-specific popen implementation
(since clone is Linux specific and it would require us to maintain a
generic implementation which uses fork and another one which uses
CLONE_VFORK with all the required machinery).

In fact think using posix_spawn should require a minimum extra memory
for each call (at least 32kb due BZ#21253 and I still think this change
is quite pessimist due current somewhat broken -fstack-check support).

So I would suggest otherwise: to use implement popen using posix_spawn
as generic code instead of current fork and avoid using the broken
vfork interface (which has been removed from POSIX 2008).


  parent reply	other threads:[~2018-09-11 20:16 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-09 22:16 Sergey Melnikov
2018-09-09 22:44 ` Zack Weinberg
2018-09-09 22:47   ` Zack Weinberg
2018-09-09 23:27     ` Sergey Melnikov
2018-09-09 23:49       ` Zack Weinberg
2018-09-10  2:50         ` Martin Buchholz
2018-09-10 15:38       ` Joseph Myers
2018-09-10 15:42         ` Zack Weinberg
2018-09-10 15:43           ` Joseph Myers
     [not found]       ` <CA+kOe0_1k_PbJ-pjHznP4AmTJUgziAdT+4vCcCRSb7GGdvbv7Q@mail.gmail.com>
2018-09-10 15:59         ` Zack Weinberg
2018-09-10 16:55           ` Martin Buchholz
2018-09-11 20:16   ` Adhemerval Zanella [this message]
2018-09-12 16:30     ` Zack Weinberg
2018-09-12 19:46       ` Martin Buchholz
2018-09-13  1:27         ` Adhemerval Zanella
2018-09-13  6:31           ` Andreas Schwab
2018-09-13 12:30             ` Adhemerval Zanella
2018-09-18  1:18           ` Martin Buchholz
2018-09-18  1:59             ` Adhemerval Zanella
2018-09-18  2:18               ` Martin Buchholz
2018-09-18  4:31               ` Rich Felker
2018-09-12 23:08       ` Adhemerval Zanella
2018-09-13 12:11       ` Szabolcs Nagy
2018-09-14 18:42         ` Zack Weinberg
2018-09-17 10:32           ` Szabolcs Nagy
2018-09-17 18:27             ` Adhemerval Zanella

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=0caab9ea-5c2c-fe37-385b-090b21dd3cbb@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).