[PATCH v7 3/4] Add system-wide tunables: Apply tunables part
DJ Delorie
dj@redhat.com
Mon Jun 15 19:32:31 GMT 2026
Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> writes:
>> + if (tunable_list[tid].type.type_code == TUNABLE_TYPE_STRING)
>> + {
>> + /* This is a memory leak but there's no easy way around
>> + it, as the mapping will go away. */
>> + tunable_list[tid].val.strval.str = __strdup (value);
>> + tunable_list[tid].val.strval.len = strlen (value);
>
> I think it does not update the tunable_initialize, as per do_tunable_update_val.
Fixed.
> And is it fully safe to call malloc here? The cache is now never deallocate,
> can it just point to its value instead of strdup here?
The cache might be deallocated if ld.so.cache is updated on disk, and
the program then calls dlopen - that would reload ld.so.cache and thus
unmap the old data.
I think this happens rarely enough, and needs to be first used early
enough, that the memory leak is the best solution.
I don't think we can trust that code won't cache a pointer to this data
and refer to it later, and thus crash.
More information about the Libc-alpha
mailing list