summaryrefslogtreecommitdiff
path: root/src/modules/flow
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-09-06 23:16:29 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-09-06 23:16:29 -0700
commitcce41f3a6b78358221c5789249a7db03c2e98a50 (patch)
tree1fcab0aaead1917251b404a21c158760acbbc51b /src/modules/flow
parentb75fd1eed010a73802b9a2a43579df24d5166c38 (diff)
modules/flow: fix elements overflow bug
s->count isn't always perfectly divisable by n_cpus, which is why ctxt->n_elements is computed from n_cpus * elements_per_cpu in the transition to threaded rendering for flow. That's all fine and dandy, but the ctxt->elements initialization loop was still using the vestigial s->count from the pre-threaded implementation. So on core counts where ctxt->n_elements was smaller than s->count, initialization scribbled. Thanks Sketch for assistance in chasing this down w/ASAN enabled on a box that exhibited crashing w/rtv,channels=flow.
Diffstat (limited to 'src/modules/flow')
-rw-r--r--src/modules/flow/ff.c2
-rw-r--r--src/modules/flow/flow.c7
2 files changed, 5 insertions, 4 deletions
diff --git a/src/modules/flow/ff.c b/src/modules/flow/ff.c
index f4280b9..98ac597 100644
--- a/src/modules/flow/ff.c
+++ b/src/modules/flow/ff.c
@@ -41,7 +41,7 @@ ff_t * ff_free(ff_t *ff)
ff_t * ff_new(unsigned size, void (*populator)(void *context, unsigned size, const ff_data_t *other, ff_data_t *field), void *context)
{
- ff_t *ff;
+ ff_t *ff;
ff = calloc(1, sizeof(ff_t));
if (!ff)
diff --git a/src/modules/flow/flow.c b/src/modules/flow/flow.c
index c26817a..86632a0 100644
--- a/src/modules/flow/flow.c
+++ b/src/modules/flow/flow.c
@@ -137,15 +137,16 @@ static til_module_context_t * flow_create_context(const til_module_t *module, ti
if (!ctxt)
return NULL;
+ ctxt->n_elements_per_cpu = elements_per_cpu;
+ ctxt->n_elements = elements_per_cpu * n_cpus;
+
ctxt->ff = ff_new(s->size, flow_ff_populator, ctxt);
if (!ctxt->ff)
return til_module_context_free(&ctxt->til_module_context);
- for (unsigned i = 0; i < s->count; i++)
+ for (unsigned i = 0; i < ctxt->n_elements; i++)
ctxt->elements[i] = rand_element(&ctxt->til_module_context.seed);
- ctxt->n_elements_per_cpu = elements_per_cpu;
- ctxt->n_elements = elements_per_cpu * n_cpus;
ctxt->taps.speed = til_tap_init_float(ctxt, &ctxt->speed, 1, &ctxt->vars.speed, "speed");
flow_update_taps(ctxt, stream);
© All Rights Reserved