Skip to content

Mark modules to infer from before the parallel checker replies - #16254

Merged
josevalim merged 1 commit into
elixir-lang:mainfrom
SteffenDE:sd-fix-parallel-checker-init
Dec 1, 2026
Merged

josevalim merged 1 commit into
elixir-lang:mainfrom
SteffenDE:sd-fix-parallel-checker-init

Conversation

@SteffenDE

Copy link
Copy Markdown
Contributor

Module.ParallelChecker.init/1 acknowledged its start (:proc_lib.init_ack/1) before it marked the modules of the :infer_signatures applications as :uncached in its ETS table. start_link/1 could therefore return while the table was still empty. A compilation that looked up a remote such as Integer.parse/1 in that window found no entry. fetch_export/5 returned :badmodule and the inferred signature fell back to dynamic().

The window is short, so this rarely happens on a normal run. But it can happen whenever a checker starts: in Kernel.ParallelCompiler and when a module is defined at runtime with Code.eval_*/Code.compile_*. When it does, the signatures inferred for that compilation are worse, and the type warnings depend on timing.

This PR fills the table before acknowledging. It adds no test, because the window can't be widened from the outside without changing the code.

How it was found

Module.Types.InferTest "from Elixir built-in" failed in 1 of 40 seeds of a deterministic-simulation sweep of the stdlib suite In the failing run the test got:

{:infer, nil, [{[term()], dynamic()}]}

How it was verified

  • On BEAM (OTP 29.1.3), Process.sleep(50) after :proc_lib.init_ack/1 on main makes the test fail every time. With this change and the same sleep, it passes.
  • The stdlib suite passes on BEAM with this change. A second sweep of 40 more seeds showed no further failure of this test.

Assisted-by: Claude Code Opus 5.5

Module.ParallelChecker.init/1 acknowledged its start before it marked
the modules of the :infer_signatures applications as :uncached in its
table. A compilation that looked up a remote such as Integer.parse/1
in that window found no entry, fetch_export/5 returned :badmodule, and
the inferred signature fell back to dynamic().

On BEAM, a Process.sleep(50) after the acknowledgement makes it fail every
time; with this change it passes. Found with rotp's simulation mode.
@josevalim
josevalim merged commit 8775a8c into elixir-lang:main Dec 1, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants