Skip to content

Guard unknown ProfileFunctionId identities in the profiling report path - #66

Merged
trgibeau merged 5 commits into
user/trgibeau/profilingLib2from
copilot/fix-comments-review-thread-65
Jul 27, 2026
Merged

Guard unknown ProfileFunctionId identities in the profiling report path#66
trgibeau merged 5 commits into
user/trgibeau/profilingLib2from
copilot/fix-comments-review-thread-65

Conversation

Copilot AI commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review feedback on the library-report mapping path: frames without an IRTextFunction carry a default ProfileFunctionId whose ModuleName/FunctionName are null, which flows into report keys and can throw ArgumentNullException during module-ID mapping (and creates unstable aggregation buckets). Two adapter signatures also disagreed with their actual null usage under <Nullable>enable</Nullable>.

ProfileData.ComputeProfile

  • Normalize the frame's ProfileFunctionId before emitting a ResolvedFrame or a FunctionResolver entry, so both sides key off the same non-null identity:
var functionId = NormalizeFunctionId(details.FunctionId);
frames.Add(new ResolvedFrame(functionId, details.DebugInfo, frame.FrameRVA, ...));

// NormalizeFunctionId rebuilds via the ctor, which maps null -> string.Empty.
  • The moduleIdByName lambda returns 0 for a null name rather than throwing from GetValueOrDefault.

ProfileReportMapper

  • Only call moduleIdByName(id.ModuleName) when the name is non-null; unknown ids fall back to the "no module" id 0.
  • resolveFunction is now Func<ProfileFunctionId, IRTextFunction?>, matching the XML doc and existing call sites (which already return null for unresolved/JIT frames). No call-site changes required.

RawProfileLibraryAdapters

  • SymbolFileDescriptor? symbolFile (dereferenced with ?., passed null by callers and tests) and long[]? stackFrames / stackFrames_ (null for unknown stacks).

Note: the Core project can't be compiled in the Linux sandbox — ProfileExplorer.Profiling requires TlbImp.exe for the DIA interop — so these were verified by inspection.

Copilot AI changed the title [WIP] Fix code according to comments in review thread 65 Guard unknown ProfileFunctionId identities in the profiling report path Jul 27, 2026
Copilot AI requested a review from trgibeau July 27, 2026 16:28
@trgibeau
trgibeau requested a review from Copilot July 27, 2026 16:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the profiling report mapping pipeline against default(ProfileFunctionId) values (where ModuleName/FunctionName can be null), preventing nulls from flowing into report keys and module-ID mapping, and aligning adapter nullability annotations with actual runtime usage.

Changes:

  • Normalize ProfileFunctionId in ProfileData.ComputeProfile before emitting ResolvedFrame entries and resolver keys, so aggregation/report keys are stable and non-null.
  • Update ProfileReportMapper to allow resolveFunction to return null and to avoid calling moduleIdByName when the module name is null (mapping such frames to module id 0).
  • Fix nullability in RawProfileLibraryAdapters for optional symbol file descriptors and optional stack frames.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/ProfileExplorerCore/Profile/Data/ProfileData.cs Normalizes frame ProfileFunctionId before feeding the library profiler and adds a defensive module-id mapping lambda.
src/ProfileExplorerCore/Profile/Adapters/ProfileReportMapper.cs Makes resolveFunction nullable and guards module-id mapping for null module names.
src/ProfileExplorerCore/Profile/Adapters/RawProfileLibraryAdapters.cs Corrects nullability for optional stack frames and optional PDB identity data.

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

Comment thread src/ProfileExplorerCore/Profile/Data/ProfileData.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 7 out of 7 changed files in this pull request and generated 2 comments.

Comment thread src/ProfileExplorerCore/Profile/ProfileFunctionIdExtensions.cs Outdated
Comment thread src/ProfileExplorerCore/Profile/Data/ResolvedProfileStack.cs Outdated
@trgibeau
trgibeau marked this pull request as ready for review July 27, 2026 19:10
@trgibeau
trgibeau merged commit 22891eb into user/trgibeau/profilingLib2 Jul 27, 2026
1 check passed
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