-
Simon McVittie authored
The ld_libs data structure is pre-allocated at maximum size instead of using dynamic memory allocation, in an effort to avoid use of malloc() during critical-path interactions with basic shared library infrastructure. This makes it about 1 MiB, so if users have reduced RLIMIT_STACK from its post-1995 default of 8 MiB for whatever reason, it doesn't take many levels of recursion to exceed that limit. The symptom for a stack overflow is particularly un-diagnosable (instead of exiting unsuccessfully with an error message, the program will just segfault), so allocate this data structure on the heap instead, which gives us the opportunity to log "libcapsule: out of memory". The equivalent data structures within libcapsule itself are still allocated on the stack, to avoid introducing new memory allocation inside a critical section. Resolves: https://github.com/ValveSoftware/steam-runtime/issues/653 Signed-off-by:
Simon McVittie <smcv@collabora.com>
Simon McVittie authoredThe ld_libs data structure is pre-allocated at maximum size instead of using dynamic memory allocation, in an effort to avoid use of malloc() during critical-path interactions with basic shared library infrastructure. This makes it about 1 MiB, so if users have reduced RLIMIT_STACK from its post-1995 default of 8 MiB for whatever reason, it doesn't take many levels of recursion to exceed that limit. The symptom for a stack overflow is particularly un-diagnosable (instead of exiting unsuccessfully with an error message, the program will just segfault), so allocate this data structure on the heap instead, which gives us the opportunity to log "libcapsule: out of memory". The equivalent data structures within libcapsule itself are still allocated on the stack, to avoid introducing new memory allocation inside a critical section. Resolves: https://github.com/ValveSoftware/steam-runtime/issues/653 Signed-off-by:
Simon McVittie <smcv@collabora.com>