220 34135 <25f81ffc-011d-4ba3-9eac-5e130638a03a@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: crusader.mike@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: [proposal] specify behavior in case of
 exception allocation failure
Date: Thu, 24 Aug 2017 19:02:26 -0700 (PDT)
Lines: 164
Approved: news@gmane.org
Message-ID: <25f81ffc-011d-4ba3-9eac-5e130638a03a@isocpp.org>
References: <32371a6e-9717-4e31-b939-4cb2d6f09c88@isocpp.org>
 <35f512f9-a69f-42ae-b7b7-090a3d6dfe96@isocpp.org> <2180216.6Peda3kyM6@tjmaciei-mobl1>
 <CADvuK0KYHpSP0-M+Usw17-fH7L-0UoVJPRfesF=gD5_qg3JroA@mail.gmail.com>
 <19c778a1-649e-48fd-ba1f-6d6c067d6d37@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2105_1915166498.1503626546212"
X-Trace: blaine.gmane.org 1503626548 2405 195.159.176.226 (25 Aug 2017 02:02:28 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 25 Aug 2017 02:02:28 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDNMRQUSRIMBBM4K73GAKGQERI4MVUQ@isocpp.org Fri Aug 25 04:02:24 2017
Return-path: <std-proposals+bncBDNMRQUSRIMBBM4K73GAKGQERI4MVUQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qk0-f199.google.com ([209.85.220.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDNMRQUSRIMBBM4K73GAKGQERI4MVUQ@isocpp.org>)
	id 1dl3wz-0000Dj-DB
	for gclcip-std-proposals@m.gmane.org; Fri, 25 Aug 2017 04:02:21 +0200
Original-Received: by mail-qk0-f199.google.com with SMTP id l65sf4497052qkc.12
        for <gclcip-std-proposals@m.gmane.org>; Thu, 24 Aug 2017 19:02:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=9tuWGx6JebeCT7N8AnRm7z/3D1Ds7/Fqi177i9xDzKU=;
        b=I91UOCJrDVDvjmI1nuI7vxzzyvQuRypzEtMfovvON6Dni6qcW700OLwMRgGJBFTEp9
         SnPbKsPysKwOoMTEgpyuZixjfE8aOxYzovHPS+LhOv3s8AELULOyFBSkCZW3TAoHpL5c
         gNJ7O6MVY3k9rNoK2oMyl9AIuX3cFqKWT78P/Ce0UnlI7wHn7TdxZqJcQbEFtuKyfHmD
         W0m8wps+AxFks+BJBeA0qGvrR7W8lwK7NHdVLjHHwd9XH/A6YeIJh7VRFIS5HSc0OIsI
         q90WmOlfR/cmMmafUMuaCOc8tuJwHHc3z8R0ZKZJc1qe9T2D9aAzPTc/vCAZ0Jbt5657
         /2QQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=9tuWGx6JebeCT7N8AnRm7z/3D1Ds7/Fqi177i9xDzKU=;
        b=JpJz310M1eKCqJwFLFLKfXrG7sPVuGcX6GhQx2BfGE1+Zn2iNiOLSgMOqw7frww6Nh
         aRPueaHSjnfVlHuJZZ0OlgJDlWQZVJ0d/80ZIOQ4fisWoYxzDWMFyMGqdwRcFI4UWzGe
         wwdhD49H59V2uDKzVbkhUXa7YsW+bczNHd5qUIAHDRFnjrIJEVOzoVq54kcEAmiw6/ba
         MR/O27tBb08APhgXJtVt50p4f3hKNnbX+L+ZbT4em7zuXiUHcdzgSEVmgm76vW1H6Xob
         ye8gHPy/ZUpMEYOtu7NNyqDJrr4Y5Q31M6JbeJzQJE9g8rv0VvrwBbByW+O3fVboAAIS
         ydhg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=9tuWGx6JebeCT7N8AnRm7z/3D1Ds7/Fqi177i9xDzKU=;
        b=dYPQIVvDabwD09EbKDALTiZHyCUd7VfiG1oFFhiDISWi9Qv4H+x6T9z/gPriFqHim/
         LmeXeynzLCQAAya+avZ8JA0QNuEG+3l5IzIk8HfroQnAwRpnEzU6iY7kJIqd60PVc3eP
         YP1ZDbSDUpwZtv13Ys7wRZaP4OjF9yJT2WJsMC7vQhKb0U0Z9zJ/MqziKlnMgt18jzsp
         y0g7R2jaWV13yYM54Leg4iZTPxKNLdXzWMNJ8h4/8bNf2G2EhWHKmlzoVNZDkhpU8skk
         6Mdjgizu+UyeEyUnUipgDm3B+D+uz1ZWQ7qYIy3n6OtVxZ4X9cGzE9tWIwWkRBUZGPEs
         el1w==
X-Gm-Message-State: AHYfb5g3lmv5JSDWX+Kr/oAbw9B6egAfCMVKP0Tk/DInafGzAvWtrxBI
	h4x4G4zd4ntJLIJZ
X-Received: by 10.237.60.138 with SMTP id d10mr5900187qtf.11.1503626548146;
        Thu, 24 Aug 2017 19:02:28 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.134.70 with SMTP id i67ls4883941iod.12.gmail; Thu, 24 Aug
 2017 19:02:26 -0700 (PDT)
X-Received: by 10.31.63.197 with SMTP id m188mr78987vka.9.1503626546752;
        Thu, 24 Aug 2017 19:02:26 -0700 (PDT)
In-Reply-To: <19c778a1-649e-48fd-ba1f-6d6c067d6d37@isocpp.org>
X-Original-Sender: crusader.mike@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:34135
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/34135>

------=_Part_2105_1915166498.1503626546212
Content-Type: multipart/alternative; 
	boundary="----=_Part_2106_792816165.1503626546212"

------=_Part_2106_792816165.1503626546212
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable



On Thursday, August 24, 2017 at 5:12:11 PM UTC-5, Ray Hamel wrote:
>
> On Thursday, August 24, 2017 at 5:03:01 PM UTC-4, Arthur O'Dwyer wrote:
>>
>> I don't think either of you have considered that there may be multiple=
=20
>> exceptions in-flight (or else I'm missing something fundamental that you=
're=20
>> both assuming implicitly).
>>
>> Suppose we preallocate 16 bytes so that we can throw runtime_error... an=
d=20
>> then we do throw it... and then, while unwinding the stack, we throw=20
>> *another* instance of runtime_error. Don't we now have to get *another*=
=20
>> 16 bytes of storage from somewhere?
>> Not to mention, even if we only throw zero-byte objects, there's still a=
=20
>> certain amount of overhead just for the bookkeeping... I *think*. Please=
=20
>> let me know if I'm missing something here.
>>
>> See my earlier reply in this thread, which included a program that has=
=20
>> about 100 exceptions in-flight at once.
>>
>> =E2=80=93Arthur
>>
>
> Different idea; what about a function `set_oom_buffer` with the prototype
>
> // allocates an implementation-defined global thread-safe buffer
> template<std::size_t N>
> void std::set_oom_buffer();
>
> and/or
>
> // registers a buffer (UB to access or deallocate after registering)
> void std::set_oom_buffer(void *buffer, std::size_t n) noexcept;
>
> The buffer may be used by the constructor of `std::exception` and=20
> subclasses, and to construct other implementation (or user?)-defined=20
> objects, in the event that normal allocation fails.
>
> This has the advantage of (mostly) maintaining the "you don't pay for wha=
t=20
> you don't use" principle, is relatively easy to implement and wouldn't=20
> alter the semantics of existing programs.
>
> -Ray
>

Problem is that in this case I need to correctly pre-calculate my=20
'exception memory' requirements for my program to be reliable. What is=20
proposed is to have a universal solution... which can be a "safety net" for=
=20
your proposal in case if buffer is too small or program is written in such=
=20
way that these requirements aren't bounded.

=20

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/25f81ffc-011d-4ba3-9eac-5e130638a03a%40isocpp.or=
g.

------=_Part_2106_792816165.1503626546212
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Thursday, August 24, 2017 at 5:12:11 PM UTC-5, =
Ray Hamel wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"lt=
r">On Thursday, August 24, 2017 at 5:03:01 PM UTC-4, Arthur O&#39;Dwyer wro=
te:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bo=
rder-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">I don&#39;t thi=
nk either of you have considered that there may be multiple exceptions in-f=
light (or else I&#39;m missing something fundamental that you&#39;re both a=
ssuming implicitly).<div><div class=3D"gmail_quote"><div><br></div><div>Sup=
pose we preallocate 16 bytes so that we can throw runtime_error... and then=
 we do throw it... and then, while unwinding the stack, we throw <i>another=
</i> instance of runtime_error. Don&#39;t we now have to get <i>another</i>=
 16 bytes of storage from somewhere?</div><div>Not to mention, even if we o=
nly throw zero-byte objects, there&#39;s still a certain amount of overhead=
 just for the bookkeeping... I <i>think</i>. Please let me know if I&#39;m =
missing something here.</div><div><br></div><div>See my earlier reply in th=
is thread, which included a program that has about 100 exceptions in-flight=
 at once.</div><div><br></div><div>=E2=80=93Arthur</div></div></div></div><=
/blockquote><div><br></div><div>Different idea; what about a function `<spa=
n style=3D"font-family:courier new,monospace">set_oom_buffer</span>` with t=
he prototype</div><div><br></div><div><div style=3D"background-color:rgb(25=
0,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:1p=
x"><code><div><span style=3D"color:#800">// allocates an implementation-def=
ined global thread-safe buffer</span><span style=3D"color:#000"><br></span>=
<span style=3D"color:#008">template</span><span style=3D"color:#660">&lt;</=
span><span style=3D"color:#000">std</span><span style=3D"color:#660">::</sp=
an><span style=3D"color:#000">size_t N</span><span style=3D"color:#660">&gt=
;</span><span style=3D"color:#000"><br></span><span style=3D"color:#008">vo=
id</span><span style=3D"color:#000"> std</span><span style=3D"color:#660">:=
:</span><span style=3D"color:#000">set_oom_buffer</span><span style=3D"colo=
r:#660">();</span><span style=3D"color:#000"><br></span></div></code></div>=
<br>and/or<br></div><div><br></div><div><div style=3D"background-color:rgb(=
250,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:=
1px"><code><div><span style=3D"color:#800">// registers a buffer (UB to acc=
ess or deallocate after registering)</span><span style=3D"color:#000"><br><=
/span><span style=3D"color:#008">void</span><span style=3D"color:#000"> std=
</span><span style=3D"color:#660">::</span><span style=3D"color:#000">set_o=
om_buffer</span><span style=3D"color:#660">(</span><span style=3D"color:#00=
8">void</span><span style=3D"color:#000"> </span><span style=3D"color:#660"=
>*</span><span style=3D"color:#000">buffer</span><span style=3D"color:#660"=
>,</span><span style=3D"color:#000"> std</span><span style=3D"color:#660">:=
:</span><span style=3D"color:#000">size_t n</span><span style=3D"color:#660=
">)</span><span style=3D"color:#000"> noexcept</span><span style=3D"color:#=
660">;</span></div></code></div><br>The buffer may be used by the construct=
or of `<span style=3D"font-family:courier new,monospace">std::exception</sp=
an>` and subclasses, and to construct other implementation (or user?)-defin=
ed objects, in the event that normal allocation fails.</div><div><br></div>=
<div>This has the advantage of (mostly) maintaining the &quot;you don&#39;t=
 pay for what you don&#39;t use&quot; principle, is relatively easy to impl=
ement and wouldn&#39;t alter the semantics of existing programs.<br></div><=
div><br></div><div>-Ray<br></div></div></blockquote><div><br></div><div>Pro=
blem is that in this case I need to correctly pre-calculate my &#39;excepti=
on memory&#39; requirements for my program to be reliable. What is proposed=
 is to have a universal solution... which can be a &quot;safety net&quot; f=
or your proposal in case if buffer is too small or program is written in su=
ch way that these requirements aren&#39;t bounded.</div><div><br></div><div=
>=C2=A0</div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/25f81ffc-011d-4ba3-9eac-5e130638a03a%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/25f81ffc-011d-4ba3-9eac-5e130638a03a=
%40isocpp.org</a>.<br />

------=_Part_2106_792816165.1503626546212--

------=_Part_2105_1915166498.1503626546212--

.
