Skip to content

Fix md_parse_sequence_points document and rolling value bugs#68

Merged
AaronRobinsonMSFT merged 1 commit intomasterfrom
fix/sequence-points-document-cursor
Mar 7, 2026
Merged

Fix md_parse_sequence_points document and rolling value bugs#68
AaronRobinsonMSFT merged 1 commit intomasterfrom
fix/sequence-points-document-cursor

Conversation

@AaronRobinsonMSFT
Copy link
Owner

@AaronRobinsonMSFT AaronRobinsonMSFT commented Mar 7, 2026

Problem

Two bugs in md_parse_sequence_points():

Bug 1: Document cursor not set from row column

When the MethodDebugInformation row has a non-null Document column (the common case for single-document methods), the parser reads it into a local document cursor but never copies it to sequence_points->document. The field is left at the invalid row-0 default from create_cursor(&cxt->tables[mdtid_Document], 0), causing callers that try to resolve the document name to fail.

Bug 2: Rolling values not accumulated

The rolling_il_offset, rolling_start_line, and rolling_start_column fields store raw blob values instead of accumulated running sums. The Portable PDB spec delta-encodes these values — the first record is absolute, subsequent records are signed deltas from the previous — but the parser stored the raw deltas. This caused incorrect source locations for any sequence point after the first in a method.

Example: A method starting at line 69 with sequence points at lines 69, 70, 71 would instead report lines 69, 1, 1 (the raw deltas).

Fix

  1. When the Document column is non-null, use the cursor directly as sequence_points->document.
  2. Maintain running_il, running_line, and running_col accumulators across the record loop.

@AaronRobinsonMSFT AaronRobinsonMSFT force-pushed the fix/sequence-points-document-cursor branch from aa2eb84 to d65ed1a Compare March 7, 2026 06:44
@AaronRobinsonMSFT
Copy link
Owner Author

Updated: The force-pushed commit now fixes a second bug in the same function — the rolling_il_offset, rolling_start_line, and rolling_start_column fields were storing raw deltas instead of accumulated running sums. This caused incorrect source locations for any sequence point after the first in a method (e.g., line 69 → 70 → 71 would report as 69 → 1 → 1).

@AaronRobinsonMSFT AaronRobinsonMSFT changed the title Fix md_parse_sequence_points not setting document from row column Fix md_parse_sequence_points document and rolling value bugs Mar 7, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Portable PDB SequencePoints parsing so md_parse_sequence_points() correctly sets the initial document cursor from the MethodDebugInformation.Document column (the common single-document case), aligning behavior with the Portable PDB spec.

Changes:

  • Set sequence_points->document from the non-null MethodDebugInformation.Document column; only read InitialDocument from the blob when the column is null.
  • Accumulate delta-encoded ILOffset/StartLine/StartColumn into rolling (absolute) values for output records.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Two bugs in sequence point parsing:

1. When the MethodDebugInformation row has a non-null Document
   column (the common case for single-document methods), the parser
   read the cursor into a local variable but never copied it to
   sequence_points->document. The field was left at an invalid row-0
   default, causing callers to fail when resolving the document name.

2. The rolling_il_offset, rolling_start_line, and rolling_start_column
   fields were not accumulated. The Portable PDB spec delta-encodes
   these values (absolute for the first record, signed deltas for
   subsequent records), but the parser stored raw deltas instead of
   running sums. This caused incorrect source locations for any
   sequence point after the first.

Fix both by:
  - Copying the Document column cursor directly when non-null.
  - Maintaining running accumulators for IL offset, start line,
    and start column across records.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@AaronRobinsonMSFT
Copy link
Owner Author

@jkoritzinsky I'm going to commit this to unblock myself. If this doesn't make sense to you, we can revert and put up a proper fix. We should do some brain storming on testing shortly though.

@AaronRobinsonMSFT AaronRobinsonMSFT merged commit d494070 into master Mar 7, 2026
17 checks passed
@AaronRobinsonMSFT AaronRobinsonMSFT deleted the fix/sequence-points-document-cursor branch March 7, 2026 19:10
@jkoritzinsky
Copy link
Collaborator

Yeah we don't have a good testing story for the portable PDB blob formats at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants