Fixed (Critical null pointer bug) in incremental builder#61807
Closed
DrHazemAli wants to merge 1 commit intomicrosoft:mainfrom
Closed
Fixed (Critical null pointer bug) in incremental builder#61807DrHazemAli wants to merge 1 commit intomicrosoft:mainfrom
DrHazemAli wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Compiler Fix: resolve critical null pointer bug in builder and diagnostic property mappings - Fix undefined handling for affectedFilesIndex in getNextAffectedFile function - Correct property mappings between Diagnostic.reportsDeprecated and ReusableDiagnostic.reportDeprecated - Prevent potential runtime crashes in incremental compilation when affectedFilesIndex is undefined - Ensure proper type conversion in diagnostic serialization/deserialization functions Fixes critical issue where BuilderProgramState.affectedFilesIndex could be undefined but was accessed with non-null assertion, causing potential runtime errors during incremental builds.
Collaborator
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
sheetalkamat
requested changes
Jun 3, 2025
Member
sheetalkamat
left a comment
There was a problem hiding this comment.
These changes are invariants in builder state and thats why are asserts
Author
|
Thanks for clarifying! I see now. I’ll go ahead and close this PR since the implementation is correct by design. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
This PR addresses a critical null pointer issue in TypeScript's incremental compilation builder system and fixes property mapping inconsistencies in diagnostic conversion functions.
Issues Fixed
1. Critical Null Pointer Bug in Builder System
src/compiler/builder.tslines 643 and 2147state.affectedFilesIndexwas accessed with non-null assertion (!) despite being defined asnumber | undefinedin theBuilderProgramStateinterfaceaffectedFilesIndexis undefined during incremental builds??)2. Diagnostic Property Mapping Inconsistencies
src/compiler/builder.tslines 577 and 1507DiagnosticandReusableDiagnostictypes:DiagnostichasreportsDeprecatedpropertyReusableDiagnostichasreportDeprecatedpropertyconvertToDiagnostics:diagnostic.reportDeprecated→result.reportsDeprecatedtoReusableDiagnostic:diagnostic.reportsDeprecated→result.reportDeprecatedTechnical Details
The
affectedFilesIndextracks the current position when iterating through files affected by changes in incremental compilation. The interface correctly allows this to beundefined, but the implementation incorrectly assumed it was always defined.This bug could manifest during:
Code Changes
Risk Assessment
Low Risk: Changes only affect error-prone undefined access patterns and incorrect property mappings. The fixes make the code more robust and type-safe without changing core functionality.
Consideration
The following line
644Was commented as
TODO: GH#18217Testing Notes
hereby runtests) should be run to ensure no regressions