qwen4exp: the pinned window copy survives its model's reset

declare() resets the rank's Model with Model{} on every re-declare --
every rebuild, every sizing probe, every test case -- and the reset
drops pipe_cu_h, the once-made pinned copy of the window bounds, on the
floor: the pointer is overwritten and the pin leaks. arch_test flags it
under the asan tier (qsa_a_widened_step...: 8 bytes, calloc,
pipe_bounds), and the leak grows one pin per re-declare of a rank.

Free the copy where it is dropped. The copy is read only by a widened
step's memcpys, and no step runs across a declare.
This commit is contained in:
fl0l0u authored and StillDeadcode committed 2026-10-31 07:50:43 +01:00
1 parent 8e65e1a302
commit 3decb3ca13
1 file changed
+4
+4
View File
@@ -273,6 +273,10 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
* real max_tok (RadBuildCtx::shape_probe). */
static thread_local Model probe_model;
Model& m = ctx->shape_probe ? probe_model : g_model[ctx->rank];
/* The reset drops the pinned window copy (pipe_bounds); free it first -- a re-declare of the
* same rank (every rebuild, every test case) otherwise overwrites the pointer and leaks the
* pin. The copy is read only by a step's memcpys, and no step runs across a declare. */
if (m.pipe_cu_h) rad_dev_free(m.pipe_cu_h, RAD_MEM_HOST_PINNED);
m = Model{};
m.nm = Names(ctx->scope ? ctx->scope : "");
Names& nm = m.nm;