Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #70108 > unrolled thread
| Started by | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| First post | 2019-11-13 17:59 +0100 |
| Last post | 2019-11-14 13:07 +0100 |
| Articles | 18 — 7 participants |
Back to article view | Back to comp.lang.c++
Where are the exception-objects allocated? Bonita Montero <Bonita.Montero@gmail.com> - 2019-11-13 17:59 +0100
Re: Where are the exception-objects allocated? Öö Tiib <ootiib@hot.ee> - 2019-11-13 10:10 -0800
Re: Where are the exception-objects allocated? Bonita Montero <Bonita.Montero@gmail.com> - 2019-11-13 19:14 +0100
Re: Where are the exception-objects allocated? Öö Tiib <ootiib@hot.ee> - 2019-11-13 10:24 -0800
Re: Where are the exception-objects allocated? Bonita Montero <Bonita.Montero@gmail.com> - 2019-11-13 19:27 +0100
Re: Where are the exception-objects allocated? Öö Tiib <ootiib@hot.ee> - 2019-11-13 10:40 -0800
Re: Where are the exception-objects allocated? Bonita Montero <Bonita.Montero@gmail.com> - 2019-11-13 19:44 +0100
Re: Where are the exception-objects allocated? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2019-11-13 21:58 -0800
Re: Where are the exception-objects allocated? James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-11-13 10:18 -0800
Re: Where are the exception-objects allocated? Bonita Montero <Bonita.Montero@gmail.com> - 2019-11-13 19:28 +0100
Re: Where are the exception-objects allocated? James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-11-13 10:44 -0800
Re: Where are the exception-objects allocated? Bonita Montero <Bonita.Montero@gmail.com> - 2019-11-13 19:46 +0100
Re: Where are the exception-objects allocated? Bonita Montero <Bonita.Montero@gmail.com> - 2019-11-13 20:06 +0100
Re: Where are the exception-objects allocated? Öö Tiib <ootiib@hot.ee> - 2019-11-13 11:36 -0800
Re: Where are the exception-objects allocated? scott@slp53.sl.home (Scott Lurndal) - 2019-11-13 19:41 +0000
Re: Where are the exception-objects allocated? Ian Collins <ian-news@hotmail.com> - 2019-11-14 20:11 +1300
Re: Where are the exception-objects allocated? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-11-14 12:42 +0100
Re: Where are the exception-objects allocated? Bonita Montero <Bonita.Montero@gmail.com> - 2019-11-14 13:07 +0100
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2019-11-13 17:59 +0100 |
| Subject | Where are the exception-objects allocated? |
| Message-ID | <qqhcq2$ked$1@news.albasani.net> |
Can anyone tell me what would be a proper way to allocate storage for an exception-object being thrown without causing that this allocation might fail? And remember that these objects even have to live longer than a thread because you might refer to it by an std::exception_ptr.
[toc] | [next] | [standalone]
| From | Öö Tiib <ootiib@hot.ee> |
|---|---|
| Date | 2019-11-13 10:10 -0800 |
| Message-ID | <56c19176-b2c7-4b49-8b09-8b64095cc25e@googlegroups.com> |
| In reply to | #70108 |
On Wednesday, 13 November 2019 18:59:58 UTC+2, Bonita Montero wrote: > Can anyone tell me what would be a proper way to allocate storage > for an exception-object being thrown without causing that this > allocation might fail? And remember that these objects even have > to live longer than a thread because you might refer to it by > an std::exception_ptr. Does not matter. Implementation makes copy of it as temporary object in unspecified storage during throw expression. Implementation destroys it when last exception_ptr to it is destroyed or when catch clause that caught it is left without rethrow ... whatever happens last.
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2019-11-13 19:14 +0100 |
| Message-ID | <qqhh6u$8mp$1@news.albasani.net> |
| In reply to | #70109 |
> On Wednesday, 13 November 2019 18:59:58 UTC+2, Bonita Montero wrote: >> Can anyone tell me what would be a proper way to allocate storage >> for an exception-object being thrown without causing that this >> allocation might fail? And remember that these objects even have >> to live longer than a thread because you might refer to it by >> an std::exception_ptr. > Does not matter. ... It does matter because it is interesting and no one seems to know it.
[toc] | [prev] | [next] | [standalone]
| From | Öö Tiib <ootiib@hot.ee> |
|---|---|
| Date | 2019-11-13 10:24 -0800 |
| Message-ID | <ad29a1f7-0703-4f27-a4b4-1eeec527fdad@googlegroups.com> |
| In reply to | #70110 |
On Wednesday, 13 November 2019 20:15:05 UTC+2, Bonita Montero wrote: > > On Wednesday, 13 November 2019 18:59:58 UTC+2, Bonita Montero wrote: > >> Can anyone tell me what would be a proper way to allocate storage > >> for an exception-object being thrown without causing that this > >> allocation might fail? And remember that these objects even have > >> to live longer than a thread because you might refer to it by > >> an std::exception_ptr. > > > Does not matter. ... > > It does matter because it is interesting and no one seems to know it. I answered precisely why and you snipped it and then claimed that I did not know it? :D You can not allocate these objects, Implementation does it into unspecified storage.
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2019-11-13 19:27 +0100 |
| Message-ID | <qqhhun$7fr$1@news.albasani.net> |
| In reply to | #70112 |
>>> On Wednesday, 13 November 2019 18:59:58 UTC+2, Bonita Montero wrote: >>>> Can anyone tell me what would be a proper way to allocate storage >>>> for an exception-object being thrown without causing that this >>>> allocation might fail? And remember that these objects even have >>>> to live longer than a thread because you might refer to it by >>>> an std::exception_ptr. >>> Does not matter. ... >> It does matter because it is interesting and no one seems to know it. > I answered precisely ... "unspecified storage" isn't a precise answer.
[toc] | [prev] | [next] | [standalone]
| From | Öö Tiib <ootiib@hot.ee> |
|---|---|
| Date | 2019-11-13 10:40 -0800 |
| Message-ID | <2b73707a-86c3-4bf3-80c1-38ff2db3911f@googlegroups.com> |
| In reply to | #70113 |
On Wednesday, 13 November 2019 20:27:47 UTC+2, Bonita Montero wrote: > >>> On Wednesday, 13 November 2019 18:59:58 UTC+2, Bonita Montero wrote: > >>>> Can anyone tell me what would be a proper way to allocate storage > >>>> for an exception-object being thrown without causing that this > >>>> allocation might fail? And remember that these objects even have > >>>> to live longer than a thread because you might refer to it by > >>>> an std::exception_ptr. > > >>> Does not matter. ... > > >> It does matter because it is interesting and no one seems to know it. > > > I answered precisely ... > > "unspecified storage" isn't a precise answer. It is precise answer to question asked. If you want to know something that you did not ask then sorry, I'm no psychiatist.
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2019-11-13 19:44 +0100 |
| Message-ID | <qqhiv7$493$1@news.albasani.net> |
| In reply to | #70115 |
>>>>> On Wednesday, 13 November 2019 18:59:58 UTC+2, Bonita Montero wrote: >>>>>> Can anyone tell me what would be a proper way to allocate storage >>>>>> for an exception-object being thrown without causing that this >>>>>> allocation might fail? And remember that these objects even have >>>>>> to live longer than a thread because you might refer to it by >>>>>> an std::exception_ptr. >>>>> Does not matter. ... >>>> It does matter because it is interesting and no one seems to know it. >>> I answered precisely ... >> "unspecified storage" isn't a precise answer. > It is precise answer to question asked. ... "unspecified" isn't precise.
[toc] | [prev] | [next] | [standalone]
| From | "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> |
|---|---|
| Date | 2019-11-13 21:58 -0800 |
| Message-ID | <qqiqe1$1bak$2@gioia.aioe.org> |
| In reply to | #70116 |
On 11/13/2019 10:44 AM, Bonita Montero wrote: >>>>>> On Wednesday, 13 November 2019 18:59:58 UTC+2, Bonita Montero wrote: >>>>>>> Can anyone tell me what would be a proper way to allocate storage >>>>>>> for an exception-object being thrown without causing that this >>>>>>> allocation might fail? And remember that these objects even have >>>>>>> to live longer than a thread because you might refer to it by >>>>>>> an std::exception_ptr. > >>>>>> Does not matter. ... > >>>>> It does matter because it is interesting and no one seems to know it. > >>>> I answered precisely ... > >>> "unspecified storage" isn't a precise answer. > >> It is precise answer to question asked. ... > > "unspecified" isn't precise. > Are you JG?
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@alumni.caltech.edu> |
|---|---|
| Date | 2019-11-13 10:18 -0800 |
| Message-ID | <3003e593-126c-4374-ad9f-f3f42e9c10b4@googlegroups.com> |
| In reply to | #70108 |
On Wednesday, November 13, 2019 at 11:59:58 AM UTC-5, Bonita Montero wrote: > Can anyone tell me what would be a proper way to allocate storage > for an exception-object being thrown without causing that this > allocation might fail? And remember that these objects even have > to live longer than a thread because you might refer to it by > an std::exception_ptr. Exception objects are not created by user code; they are temporary objects created by the implementation, copy-initialized by the expression passed to the throw expression. It is unspecified how the implementation allocates the storage that they are stored in. The relevant wording of the standard is: 123456789012345678901234567890123456789012345678901234567890123456789012 "3 Throwing an exception copy-initializes (11.6, 15.8) a temporary object, called the exception object. An lvalue denoting the temporary is used to initialize the variable declared in the matching handler (18.3). If the type of the exception object would be an incomplete type or a pointer to an incomplete type other than cv void the program is ill- formed. 4 The memory for the exception object is allocated in an unspecified way, except as noted in 6.7.4.1." (18.1).
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2019-11-13 19:28 +0100 |
| Message-ID | <qqhi0t$7fr$2@news.albasani.net> |
| In reply to | #70111 |
>> Can anyone tell me what would be a proper way to allocate storage >> for an exception-object being thrown without causing that this >> allocation might fail? And remember that these objects even have >> to live longer than a thread because you might refer to it by >> an std::exception_ptr. > Exception objects are not created by user code; they are temporary > objects created by the implementation, copy-initialized by the > expression passed to the throw expression. It is unspecified how the > implementation allocates the storage that they are stored in. ... I know that this is unspecified. But I'm interested how this is actually implemented.
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@alumni.caltech.edu> |
|---|---|
| Date | 2019-11-13 10:44 -0800 |
| Message-ID | <9dbeef35-8d24-4e17-bfdd-f50a1ec1b78f@googlegroups.com> |
| In reply to | #70114 |
On Wednesday, November 13, 2019 at 1:28:54 PM UTC-5, Bonita Montero wrote: > >> Can anyone tell me what would be a proper way to allocate storage > >> for an exception-object being thrown without causing that this > >> allocation might fail? And remember that these objects even have > >> to live longer than a thread because you might refer to it by > >> an std::exception_ptr. > > > Exception objects are not created by user code; they are temporary > > objects created by the implementation, copy-initialized by the > > expression passed to the throw expression. It is unspecified how the > > implementation allocates the storage that they are stored in. ... > > I know that this is unspecified. > But I'm interested how this is actually implemented. Then you need to be specific about which implementations you're most interested in. For best results, you should ask in forums that are specific to those implementations. Those kinds of details are not widely known, because ordinary developers have no need to know them, so the people who do know such details are far easier to find in such specialized forums, rather than in this one.
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2019-11-13 19:46 +0100 |
| Message-ID | <qqhj2p$493$2@news.albasani.net> |
| In reply to | #70117 |
>>>> Can anyone tell me what would be a proper way to allocate storage >>>> for an exception-object being thrown without causing that this >>>> allocation might fail? And remember that these objects even have >>>> to live longer than a thread because you might refer to it by >>>> an std::exception_ptr. >>> Exception objects are not created by user code; they are temporary >>> objects created by the implementation, copy-initialized by the >>> expression passed to the throw expression. It is unspecified how the >>> implementation allocates the storage that they are stored in. ... >> I know that this is unspecified. >> But I'm interested how this is actually implemented. > Then you need to be specific about which implementations you're most interested in. For best results, you should ask in forums that are specific to those implementations. Those kinds of details are not widely known, because ordinary developers have no need to know them, so the people who do know such details are far easier to find in such specialized forums, rather than in this one. I'm not interested in some particular implementation but in feasible implementations. I thought someone here would be so creative as to have some adequate ideas.
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2019-11-13 20:06 +0100 |
| Message-ID | <qqhk7b$1bb$1@news.albasani.net> |
| In reply to | #70118 |
> I'm not interested in some particular implementation but in feasible > implementations. I thought someone here would be so creative as to > have some adequate ideas. I just found this (https://libcxxabi.llvm.org/spec.html): | void* __cxa_allocate_exception(size_t thrown_size) throw(); | Effects: Allocates memory to hold the exception to be thrown. | thrown_size is the size of the exception object. Can allocate | additional memory to hold private data. If memory can not be | allocated, call std::terminate(). | Returns: A pointer to the memory allocated for the exception object.
[toc] | [prev] | [next] | [standalone]
| From | Öö Tiib <ootiib@hot.ee> |
|---|---|
| Date | 2019-11-13 11:36 -0800 |
| Message-ID | <1af57162-cca6-4697-b065-1850001a8767@googlegroups.com> |
| In reply to | #70118 |
On Wednesday, 13 November 2019 20:46:58 UTC+2, Bonita Montero wrote: > >>>> Can anyone tell me what would be a proper way to allocate storage > >>>> for an exception-object being thrown without causing that this > >>>> allocation might fail? And remember that these objects even have > >>>> to live longer than a thread because you might refer to it by > >>>> an std::exception_ptr. > > >>> Exception objects are not created by user code; they are temporary > >>> objects created by the implementation, copy-initialized by the > >>> expression passed to the throw expression. It is unspecified how the > >>> implementation allocates the storage that they are stored in. ... > > >> I know that this is unspecified. > >> But I'm interested how this is actually implemented. > > > Then you need to be specific about which implementations you're most interested in. For best results, you should ask in forums that are specific to those implementations. Those kinds of details are not widely known, because ordinary developers have no need to know them, so the people who do know such details are far easier to find in such specialized forums, rather than in this one. > > I'm not interested in some particular implementation but in feasible > implementations. I thought someone here would be so creative as to > have some adequate ideas. Huh? Each implementation does something feasible. IIRC then gcc version where I looked in tried first to malloc and if that failed then tried to use emergency buffer that it had reserved for desperate times and if that was used up then called std::terminate.
[toc] | [prev] | [next] | [standalone]
| From | scott@slp53.sl.home (Scott Lurndal) |
|---|---|
| Date | 2019-11-13 19:41 +0000 |
| Message-ID | <H%YyF.60106$kt1.41492@fx46.iad> |
| In reply to | #70117 |
James Kuyper <jameskuyper@alumni.caltech.edu> writes: >On Wednesday, November 13, 2019 at 1:28:54 PM UTC-5, Bonita Montero wrote: >> >> Can anyone tell me what would be a proper way to allocate storage >> >> for an exception-object being thrown without causing that this >> >> allocation might fail? And remember that these objects even have >> >> to live longer than a thread because you might refer to it by >> >> an std::exception_ptr. >>=20 >> > Exception objects are not created by user code; they are temporary >> > objects created by the implementation, copy-initialized by the >> > expression passed to the throw expression. It is unspecified how the >> > implementation allocates the storage that they are stored in. ... >>=20 >> I know that this is unspecified. >> But I'm interested how this is actually implemented. > >Then you need to be specific about which implementations you're most intere= >sted in. For best results, you should ask in forums that are specific to th= >ose implementations. Those kinds of details are not widely known, because o= >rdinary developers have no need to know them, so the people who do know suc= >h details are far easier to find in such specialized forums, rather than in= > this one. Or BM could simply download the compiler sources and figure it out.
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2019-11-14 20:11 +1300 |
| Message-ID | <h34d0vF4cl5U11@mid.individual.net> |
| In reply to | #70121 |
On 14/11/2019 08:41, Scott Lurndal wrote: > James Kuyper <jameskuyper@alumni.caltech.edu> writes: >> On Wednesday, November 13, 2019 at 1:28:54 PM UTC-5, Bonita Montero wrote: >>>>> Can anyone tell me what would be a proper way to allocate storage >>>>> for an exception-object being thrown without causing that this >>>>> allocation might fail? And remember that these objects even have >>>>> to live longer than a thread because you might refer to it by >>>>> an std::exception_ptr. >>> =20 >>>> Exception objects are not created by user code; they are temporary >>>> objects created by the implementation, copy-initialized by the >>>> expression passed to the throw expression. It is unspecified how the >>>> implementation allocates the storage that they are stored in. ... >>> =20 >>> I know that this is unspecified. >>> But I'm interested how this is actually implemented. >> >> Then you need to be specific about which implementations you're most intere= >> sted in. For best results, you should ask in forums that are specific to th= >> ose implementations. Those kinds of details are not widely known, because o= >> rdinary developers have no need to know them, so the people who do know suc= >> h details are far easier to find in such specialized forums, rather than in= >> this one. > > Or BM could simply download the compiler sources and figure it out. Rude trolls don't do that.. -- Ian.
[toc] | [prev] | [next] | [standalone]
| From | "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> |
|---|---|
| Date | 2019-11-14 12:42 +0100 |
| Message-ID | <qqjeia$lt$1@dont-email.me> |
| In reply to | #70108 |
On 13.11.2019 17:59, Bonita Montero wrote: > Can anyone tell me what would be a proper way to allocate storage > for an exception-object being thrown without causing that this > allocation might fail? And remember that these objects even have > to live longer than a thread because you might refer to it by > an std::exception_ptr. For string data you can leverage the internal special immutable string class by using `std::runtime_error` or a derived class. It can of course throw when the original exception is created, but after that it's guaranteed that copying does not throw: C++17 §21.8.2/2: “Each standard library class T that derives from class exception shall have a publicly accessible copy constructor and a publicly accessible copy assignment operator that do not exit with an exception.” For other data you have to ensure this guarantee yourself. A reasonable approach is to minimize the amount of other data in an exception. - Alf
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2019-11-14 13:07 +0100 |
| Message-ID | <qqjg1v$sju$1@news.albasani.net> |
| In reply to | #70136 |
> C++17 §21.8.2/2:
> “Each standard library class T that derives from class exception shall
> have a publicly accessible copy constructor and a publicly accessible
> copy assignment operator that do not exit with an exception.”
1. I'm talking about the storage for the exception-object itself;
this isn't allocated by your own code but the rundime-library.
2. I just posted my parallel merge-sort-algorithm. It gathers the
exceptions which might occur in the sorting-threads in a single
pre-allocated vector of exception_ptr's and moves this vector
inside the exception which might be thrown later. If I would
provide a copy-costructor or assignment-operator, this vector
would be copied and an exception might get thrown. This might
occur when you don't catch the exception by reference (I don't
see any reason to catch exception-objects by value anyway). So
there are good reasons to not to provide both.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c++
csiph-web