mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: Pirmin Walthert <pirmin.walthert@wwcom.ch>
Cc: musl@lists.openwall.com
Subject: Re: [musl] Re: FYI: some observations when testing next-gen malloc
Date: Tue, 10 Mar 2020 11:06:57 +0100	[thread overview]
Message-ID: <20200310100657.GK14278@port70.net> (raw)
In-Reply-To: <5957e47c-50c6-0ae1-3e5c-32fd96c756eb@wwcom.ch>

* Pirmin Walthert <pirmin.walthert@wwcom.ch> [2020-03-10 10:44:46 +0100]:
> Am 09.03.20 um 19:55 schrieb Szabolcs Nagy:
> > * Pirmin Walthert <pirmin.walthert@wwcom.ch> [2020-03-09 19:14:59 +0100]:
> > > Am 09.03.20 um 18:12 schrieb Rich Felker:
> > > > It's not described very rigorously, but effectively it's in an async
> > > > signal context and can only call functions which are AS-safe.
> > > > 
> > > > A future version of the standard is expected to drop the requirement
> > > > that fork itself be async-signal-safe, and may thereby add
> > > > requirements to synchronize against some or all internal locks so that
> > > > the child can inherit a working context. But the right solution here is
> > > > always to stop using fork without exec.
> > > > 
> > > > Rich
> > > Well, I have now changed the code a bit to make sure that no
> > > async-signal-unsafe command is being executed before execl. Things I've
> > > removed:
> > > 
> > > a call to cap_from_text, cap_set_proc and cap_free has been removed as well
> > > as sched_setscheduler. Now the only thing being executed before execl in the
> > > child process is closefrom()
> > 
> > closefrom is not as-safe.
> > 
> > i think it reads /proc/self/fd directory to close fds.
> > (haven't checked the specific asterisk version)
> > opendir calls malloc so it can deadlock.
> > 
> Indeed I am not able to reproduce the problem any longer with a modified
> version of asterisk. What I've changed is:
> 
> Removed some code that sets the capabilities after fork() (with
> cap_from_text, cap_set_proc, cap_free) and closefrom replaced with a thumb
> loop over all possible fds up to sysconf(_SC_OPEN_MAX). With this
> modification the fd closing procedure with max open files set to 21471 now
> needs 7ms instead of 70ns (so a slowdown by times 100), however this is not
> critical in our environment...
> 
> Will discuss the findings with the asterisk developers.
> 
> Thanks for your hints!

good.

ideally they would use close-on-exec fds and then
you don't need such ugliness.

please don't drop the list from replies.

  parent reply	other threads:[~2020-03-10 10:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <41ea935d-39e4-1460-e502-5c82d7dd6a4d@wwcom.ch>
2020-03-09 17:12 ` Rich Felker
2020-03-09 18:14   ` Pirmin Walthert
2020-03-09 18:55     ` Szabolcs Nagy
     [not found]       ` <5957e47c-50c6-0ae1-3e5c-32fd96c756eb@wwcom.ch>
2020-03-10 10:06         ` Szabolcs Nagy [this message]
2020-03-11  0:47           ` Rich Felker
2020-03-11  8:54             ` Pirmin Walthert

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=20200310100657.GK14278@port70.net \
    --to=nsz@port70.net \
    --cc=musl@lists.openwall.com \
    --cc=pirmin.walthert@wwcom.ch \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).