diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-08-30 17:35:25 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-08-30 18:34:08 -0700 |
| commit | 56cfa8f22f69d813efedb1fa01fdcb7077ca0e5a (patch) | |
| tree | abefcd7eb5be87432d75e8f3abd971539a3938d3 /lib/std/Thread.zig | |
| parent | 35e0ff7c364487152d786347cf70f47b2a390f12 (diff) | |
| download | zig-56cfa8f22f69d813efedb1fa01fdcb7077ca0e5a.tar.gz zig-56cfa8f22f69d813efedb1fa01fdcb7077ca0e5a.zip | |
Sema: prevent access of undefined fields
When instantiating a generic function, there is a period of time where
the function is inserted into monomorphed_funcs map, but is not yet
initialized. Despite semantic analysis being single-threaded, generic
function instantiation can happen recursively, meaning that the hash
and equality functions for monomorphed_funcs entries are potentially
invoked for an uninitialized function.
This problem was mitigated by pre-setting the hash field on the newly
allocated function, however it did not solve the problem for hash
collisions in which case the equality function would be invoked. That it
was solved for hash() but not eql() explains why the problem was
difficult to observe. I tested this patch by temporarily sabotaging the
hash and making it always return 0.
This fix is centered on adding a new field to Module.Fn which is the one
checked by eql() and is populated pre-initialization.
closes #12643
Diffstat (limited to 'lib/std/Thread.zig')
0 files changed, 0 insertions, 0 deletions
