[PATCH] check_native: Get rid of alloca
Florian Weimer
fweimer@redhat.com
Thu Jun 1 08:47:15 GMT 2023
* Andreas Schwab:
> On Jun 01 2023, Florian Weimer wrote:
>
>> * Andreas Schwab:
>>
>>> On Jun 01 2023, Florian Weimer via Libc-alpha wrote:
>>>
>>>> * Adhemerval Zanella Netto via Libc-alpha:
>>>>
>>>>> +static void
>>>>> +iclose (int *fd)
>>>>> +{
>>>>> + if (*fd >= 0)
>>>>> + __close_nocancel_nostatus (*fd);
>>>>> +}
>>>>> +
>>>>> void
>>>>> __check_native (uint32_t a1_index, int *a1_native,
>>>>> uint32_t a2_index, int *a2_native)
>>>>> {
>>>>> - int fd = __socket (PF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE);
>>>>> + int __attribute__ ((__cleanup__ (iclose))) fd
>>>>> + = __socket (PF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE);
>>>>> + if (fd < 0)
>>>>> + return;
>>>>
>>>> I think introducing attribute cleanup where equivalent functionality can
>>>> be implemented otherwise requires a discussion first.
>>>
>>> The cleanup attribute requires compiling the function and all callees
>>> with -fasynchronous-unwind-tables.
>>
>> I think GCC will still call the destructor on normal scope exit (if no
>> exception is thrown), even with -fno-exceptions. That should be
>> sufficient here?
>
> The cancellation could be asynchronous.
The current code does handle cancellation. Isn't sendto a cancellation
point?
In any case, we'd have to build with -fexceptions to turn the destructor
into a cancellation handler, not -fasynchronous-unwind-tables.
Thanks,
Florian
More information about the Libc-alpha
mailing list