Re: How to use __forced_unwind?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2023-05-31 22:28, Jonathan Wakely wrote:
> On Wed, 31 May 2023 at 21:27, J.W. Jagersma <jwjagersma@xxxxxxxxx> wrote:
>>
>> On 2023-05-31 22:24, Jonathan Wakely wrote:
>>> On Wed, 31 May 2023 at 21:23, J.W. Jagersma <jwjagersma@xxxxxxxxx> wrote:
>>>>
>>>> On 2023-05-31 22:18, Jonathan Wakely wrote:
>>>>> On Wed, 31 May 2023 at 21:15, J.W. Jagersma via Gcc-help
>>>>> <gcc-help@xxxxxxxxxxx> wrote:
>>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> In my cooperative scheduler I currently use a regular exception type for thread
>>>>>> cancellation.  But these tend to get eaten, for example by std::iosteam
>>>>>> functions.
>>>>>>
>>>>>> Now I see those functions do catch and rethrow a __cxxabiv1::__forced_unwind
>>>>>> type, and I presume such an object can be thrown via _Unwind_ForcedUnwind().
>>>>>>
>>>>>> But how do you actually use it?
>>>>>
>>>>> You don't. It exists for pthread_kill, not for users.
>>>>>
>>>>>> Specifically, how is the exception supposed to
>>>>>> be allocated, who is in charge of freeing it,
>>>>>
>>>>> The runtime does that as needed.
>>>>>
>>>>>> and how do you make sure it stops
>>>>>> where you want it to?
>>>>>
>>>>> You can't, it can never be stopped. If it is caught and not rethrown
>>>>> then the entire process is aborted. It must propagate to the initial
>>>>> function that was executed in the thread, and then when it leaves that
>>>>> function the thread is terminated.
>>>>
>>>> Okay, that's a bit unfortunate.  But why is it exposed in a public header then
>>>> if it's never supposed to be used by anyone?
>>>>
>>>> I understand doing something like this from user code is extremely messy,
>>>> but... that's how these things are.
>>>
>>> Why not just use pthread_kill(0) if you want a __forced_unwind exception?
>>
>> Single-threaded target, I don't have pthreads.  That's why I rolled my own.
> 
> Then you couldn't use __forced_unwind anyway, it would always
> terminate the program.

But _Unwind_ForcedUnwind() does take a pointer to a "stop" function, what does
that do then?




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux