Repository navigation
Return [] instead of raising on corrupt beam in Normalized.Typespec - #346
Merged
Merged
Conversation
Code.Typespec.fetch_* delegates to :beam_lib, which only catches throws. A malformed or truncated .beam (e.g. one being rewritten by a concurrent compile) raises MatchError/ArgumentError out of completion and signature help. Treat any raise/exit/throw from the fetch as :error so get_specs, get_types and get_callbacks return [].
This was referenced Oct 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Completion and signature help crash when a module's
.beamis malformed or truncated (e.g. while being rewritten by a concurrent compile)::beam_lib.read_info/1only catches throws, soerror/exitexceptions from parsing corrupt chunks escapeCode.Typespec.fetch_*.Fix
ElixirSense.Core.Normalized.Typespec.get_specs/1,get_types/1andget_callbacks/1now wrap theCode.Typespec.fetch_*call so any raise/exit/throw is treated as:error, which yields[].Only callers of
Code.Typespecinlib/go through this module.ExckReader(which uses:beam_libdirectly) has no callers inlib/, so it is unchanged.Test
Added a test that writes a
.beamwith one byte flipped at offset 25 (inside the atom chunk) to a temp dir on the code path. Without the fix it raisesMatchErrorfrom:beam_lib; with the fix all three functions return[].