Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c > #6072

OOM and N2471 (Stackable, thread local, signal guards)

Message-ID <7fd2mg-7bh1.ln1@wilbur.25thandClement.com> (permalink)
From William Ahern <william@25thandClement.com>
Subject OOM and N2471 (Stackable, thread local, signal guards)
Newsgroups comp.std.c
Date 2020-04-08 19:21 -0700

Show all headers | View raw


I just read through N2471, a proposal to add signal guards to C and C++:

  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2471.pdf

One of the stated goals is to be able to catch OOM events in C++ code that
no longer throws C++-style exceptions on allocation failure. See, e.g., sec.
1.1 item 4.

However, the proposal disallows invoking async signal safe functions within
guarded code sections. Sec. 3.

Traditionally the "default allocator" in C++ uses malloc, and malloc is not
async signal safe. E.g, "on Microsoft Windows, many of the Win32 APIs which
appear equivalent to POSIX ones in the list above are NOT async signal safe
because they call malloc() e.g. CreateFile()." ibid.

The prohibition on async signal functions in tandem with the expectation
(and goal) for guarded code to use the C++ new operator seems incongruous. I
realize that the new operator is technically a black box; strictly speaking
malloc being async signal safe is irrelevant to the async signal safety of
the C++ new operator (at least from the perspective of the C standard). But
it leaves me with a suspicion that some very important aspects of this
proposal haven't been clearly thought through. Even the proposal seems to
equivocate dynamic memory allocation with async signal safety: "potential
dynamic memory allocation equals lack of async signal safety." ibid.

Am I alone? Am I missing something?

Back to comp.std.c | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

OOM and N2471 (Stackable, thread local, signal guards) William Ahern <william@25thandClement.com> - 2020-04-08 19:21 -0700
  Re: OOM and N2471 (Stackable, thread local, signal guards) Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-05-08 07:56 -0700
    Re: OOM and N2471 (Stackable, thread local, signal guards) William Ahern <william@25thandClement.com> - 2020-05-08 13:01 -0700

csiph-web