Skip to content

Conversation

@maleadt
Copy link
Member

@maleadt maleadt commented Jan 16, 2026

jl_mt_assoc_by_type was hardcoding jl_method_table in its fallback path, causing jl_method_lookup_by_tt to incorrectly search the global method table when given a custom one. This resulted in two issues:

  1. Methods in custom MTs weren't found when not already cached (jl_method_lookup_by_tt doesn't find overlay method #60716)
  2. Global methods were incorrectly cached in custom MT caches, leading to stale entries after redefinition (jl_method_lookup_by_tt with overlay MT doesn't always always respect redefinitions #60712)

Fix by passing the method table through to jl_mt_assoc_by_type so it uses the correct MT for fallback lookups.

This behavior is "more strict", since jl_method_lookup_by_tt queries with a method table specified won't return global methods now, so I'm not sure if we should backport this very far. Other areas are not affected by this, e.g., GPUCompiler.jl's inference uses explicit StackedMethodTables.

Fixes #60712, fixes #60716, fixes #60702.

`jl_mt_assoc_by_type` was hardcoding `jl_method_table` in its fallback path,
causing `jl_method_lookup_by_tt` to incorrectly search the global method table
when given a custom one. This resulted in two issues:

1. Methods in custom MTs weren't found when not already cached
2. Global methods were incorrectly cached in custom MT caches, leading to
  stale entries after redefinition

Fix by passing the method table through to `jl_mt_assoc_by_type` so it uses
the correct MT for fallback lookups.
@maleadt maleadt requested a review from Keno January 16, 2026 12:40
@maleadt maleadt added the types and dispatch Types, subtyping and method dispatch label Jan 16, 2026
@maleadt maleadt added the backport 1.13 Change should be backported to release-1.13 label Jan 16, 2026
@maleadt maleadt merged commit bac801b into master Jan 17, 2026
12 checks passed
@maleadt maleadt deleted the tb/overlay_mt_cache branch January 17, 2026 12:00
@maleadt
Copy link
Member Author

maleadt commented Jan 20, 2026

This backports cleanly to 1.12 without breaking GPUCompiler, so I propose adding it to that release as well so that we'll be able to use fast method instance lookups on a released version of Julia too.

@maleadt maleadt added the backport 1.12 Change should be backported to release-1.12 label Jan 20, 2026
maleadt added a commit that referenced this pull request Jan 20, 2026
They did not reproduce the actual issue because of using cached methods from the OverlayModule.
maleadt added a commit that referenced this pull request Jan 20, 2026
They did not reproduce the actual issue because of using cached methods
from the OverlayModule.
DilumAluthge pushed a commit that referenced this pull request Jan 20, 2026
…60750)

I'm only backporting this because I know we're doing another 1.11
release anyway. This fixes bugs with GPUCompiler.jl that would otherwise
require expensive workarounds for every GPU kernel launch.
This was referenced Jan 26, 2026
@KristofferC KristofferC mentioned this pull request Feb 4, 2026
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 1.12 Change should be backported to release-1.12 backport 1.13 Change should be backported to release-1.13 types and dispatch Types, subtyping and method dispatch

Projects

None yet

2 participants