mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 00:00:11 +01:00
iris: avoid stack overflow in iris_bo_wait_syncobj()
Keep most cases using the stack as it's cheaper, but fall back to the
heap when the size gets too big.
This should fix a stack overflow reported by @rhezashan for a case
where we had lots of iris_screens.
Credits to Matt Turner and José Roberto de Souza for their work on
this issue, which led us to find its root cause.
Cc: mesa-stable
Reported-by: rheza shandikri (@rhezashan in gitlab)
Credits-to: José Roberto de Souza <jose.souza@intel.com>
Credits-to: Matt Turner <mattst88@gmail.com>
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
(cherry picked from commit 3cec15dd14)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25404>
This commit is contained in:
parent
3a257694f6
commit
2e4c04864a
1 changed files with 7 additions and 1 deletions
|
|
@ -50,6 +50,7 @@
|
|||
#include "errno.h"
|
||||
#include "common/intel_aux_map.h"
|
||||
#include "common/intel_clflush.h"
|
||||
#include "c99_alloca.h"
|
||||
#include "dev/intel_debug.h"
|
||||
#include "common/intel_gem.h"
|
||||
#include "dev/intel_device_info.h"
|
||||
|
|
@ -525,7 +526,10 @@ iris_bo_wait_syncobj(struct iris_bo *bo, int64_t timeout_ns)
|
|||
|
||||
simple_mtx_lock(&bufmgr->bo_deps_lock);
|
||||
|
||||
uint32_t handles[bo->deps_size * IRIS_BATCH_COUNT * 2 + is_external];
|
||||
const int handles_len = bo->deps_size * IRIS_BATCH_COUNT * 2 + is_external;
|
||||
uint32_t *handles = handles_len <= 32 ?
|
||||
(uint32_t *)alloca(handles_len * sizeof(*handles)) :
|
||||
(uint32_t *)malloc(handles_len * sizeof(*handles));
|
||||
int handle_count = 0;
|
||||
|
||||
if (is_external) {
|
||||
|
|
@ -575,6 +579,8 @@ iris_bo_wait_syncobj(struct iris_bo *bo, int64_t timeout_ns)
|
|||
}
|
||||
|
||||
out:
|
||||
if (handles_len > 32)
|
||||
free(handles);
|
||||
if (external_implicit_syncobj)
|
||||
iris_syncobj_reference(bufmgr, &external_implicit_syncobj, NULL);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue