This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 1/3] Fix __check_pf()/make_request() stack overflow segfault (convert to malloc)


On 1/16/14, 7:22 PM, "Ondřej Bílka" <neleai@seznam.cz> wrote:

>On Thu, Jan 16, 2014 at 05:58:31PM -0500, Banerjee, Debabrata wrote:
>>
>> 
>> Sorry I haven't had time to look into refactoring this patch more.
>>However
>> Pengcheng has volunteered to clean it up in whatever way is acceptable.
>> 
>> The caveat with using malloc is that I would expect it to be
>>significantly
>> slower than alloca, but someone can benchmark that. I believe this is a
>> hot path.
>> 
>That is tricky question, bottleneck could also be in network
>latency, probably here
>
> if (TEMP_FAILURE_RETRY (__sendto (fd, (void *) &req, sizeof (req), 0,
>                                    (struct sockaddr *) &nladdr,
>                                    sizeof (nladdr))) < 0)

That's a netlink connection to the kernel, no point in worrying about
latency here.

>A better way would be to malloc result at start and write into in6ai
>array directly, calling realloc to double size as necessary. At end we
>could optionally trim memory at end.

Less copies are good but multiple mallocs are bad. What I wonder (and have
spent no time looking at) is if getting all this data is necessary.
Clearly the end result only uses a small fraction of this data. I wonder
if any of this is necessary. My only goal with my patch was to fix the
implementation of what was there, assuming it is necessary.

-Deb


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]