Comment on attachment 8626818
0001-Bug-833117-Replace-g_slice_set_config-with-G_SLICE-e.patch
>+ // Keep the original value of the G_SLICE env variable to restore it once
>+ // we're done.
>+ mGSlice = getenv("G_SLICE");
I don't think we should assume it is safe to use mGSlice later.
man 3p getenv
"The returned string pointer might be invalidated or the string content might
be overwritten by a subsequent call to getenv(), setenv(), unsetenv(), or (if
supported) putenv()"
>+ // Disable the slice allocator, since jemalloc already uses similar layout
>+ // algorithms, and using a sub-allocator tends to increase fragmentation.
>+ // This must be done before g_thread_init() is called.
>+ setenv("G_SLICE", "always-malloc", 1);
I had intentionally chosen not to override an existing G_SLICE environment
variable so that this could be overridden or debug-blocks could be used if
desired. That's not a show-stopper, but avoiding overriding would avoid
having to copy the old value to restore.
I don't know why you are preferring setenv over putenv here.
I had chosen putenv to avoid the leak.
There is discussion about possible getenv optimizations if putenv is not used,
but I don't see this in glibc.
Comment on attachment 8626818 g_slice_ set_config- with-G_ SLICE-e. patch
0001-Bug-833117-Replace-
>+ // Keep the original value of the G_SLICE env variable to restore it once
>+ // we're done.
>+ mGSlice = getenv("G_SLICE");
I don't think we should assume it is safe to use mGSlice later.
man 3p getenv
"The returned string pointer might be invalidated or the string content might
be overwritten by a subsequent call to getenv(), setenv(), unsetenv(), or (if
supported) putenv()"
>+ // Disable the slice allocator, since jemalloc already uses similar layout
>+ // algorithms, and using a sub-allocator tends to increase fragmentation.
>+ // This must be done before g_thread_init() is called.
>+ setenv("G_SLICE", "always-malloc", 1);
I had intentionally chosen not to override an existing G_SLICE environment
variable so that this could be overridden or debug-blocks could be used if
desired. That's not a show-stopper, but avoiding overriding would avoid
having to copy the old value to restore.
I don't know why you are preferring setenv over putenv here.
I had chosen putenv to avoid the leak.
There is discussion about possible getenv optimizations if putenv is not used,
but I don't see this in glibc.
> + void (*g_thread_ init)(void* ) = (void (*)(void*)) GetSymbol(
Declare with "auto" type, if you like.