Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: BUG: nested gethparam() in element getter returns wrong outer values



On Sat, Nov 14, 2026 at 8:32 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
On Fri, Nov 13, 2026 at 2:31 AM Stig-Ørjan Smelror <smelror@xxxxxxxxx> wrote:
>
> I found a reproducible wrong-result bug in associative-array expansion in
> unmodified Zsh 5.9.2 and current upstream Git. If a native scalar getter for
> one hash element calls gethparam() for a different hash, the outer gethparam()
> can return the inner hash's values instead of its own.

I'm not sure "build and load a deliberately broken module" is
something we're really going to prevent upstream?  Unless I'm
misunderstanding this report?

There are a large number of ways to create a module that breaks the internals.

It's possible that workers/55148 might have an effect on this
particular variation; there are a couple of significant patches from
Philippe that are still pending, mostly because I've been waiting to
hear whether we're doing another version release before the git
branches diverge significantly.

The module uses the exported scalar getter, gethparam() and strgetfn().
It does not resize, delete or rewrite either hash. The outer values remain
A and B in the parameter table; gethparam("reentry_outer") returns X and Y
because paramvalarr() reuses static paramvals and numparamvals.

workers/55148 changes createparam()/unsetparam() and the paramtab naming.
It does not touch paramvalarr(), scanparamvals() or those statics, so it
does not change this result.

I agree that a module can break Zsh by mutating private structures or the
table being scanned. This case is a documented callback invoking an
exported retrieval function and receiving another parameter's values.

--
Vennlig hilsen / Kind regards,
Stig-Ørjan Smelror

"The man who reads nothing at all is better educated than the man who reads nothing but newspapers." - Thomas Jefferson



Messages sorted by: Reverse Date, Date, Thread, Author