Guard unknown ProfileFunctionId identities in the profiling report path - #66
Merged
trgibeau merged 5 commits intoJul 27, 2026
Merged
Conversation
… profiling adapters
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
Contributor
There was a problem hiding this comment.
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
ProfileFunctionIdinProfileData.ComputeProfilebefore emittingResolvedFrameentries and resolver keys, so aggregation/report keys are stable and non-null. - Update
ProfileReportMapperto allowresolveFunctionto returnnulland to avoid callingmoduleIdByNamewhen the module name is null (mapping such frames to module id0). - Fix nullability in
RawProfileLibraryAdaptersfor 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.
trgibeau
marked this pull request as ready for review
July 27, 2026 19:10
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.
Review feedback on the library-report mapping path: frames without an
IRTextFunctioncarry adefaultProfileFunctionIdwhoseModuleName/FunctionNamearenull, which flows into report keys and can throwArgumentNullExceptionduring module-ID mapping (and creates unstable aggregation buckets). Two adapter signatures also disagreed with their actual null usage under<Nullable>enable</Nullable>.ProfileData.ComputeProfileProfileFunctionIdbefore emitting aResolvedFrameor aFunctionResolverentry, so both sides key off the same non-null identity:moduleIdByNamelambda returns0for a null name rather than throwing fromGetValueOrDefault.ProfileReportMappermoduleIdByName(id.ModuleName)when the name is non-null; unknown ids fall back to the "no module" id0.resolveFunctionis nowFunc<ProfileFunctionId, IRTextFunction?>, matching the XML doc and existing call sites (which already return null for unresolved/JIT frames). No call-site changes required.RawProfileLibraryAdaptersSymbolFileDescriptor? symbolFile(dereferenced with?., passed null by callers and tests) andlong[]? stackFrames/stackFrames_(null for unknown stacks).Note: the Core project can't be compiled in the Linux sandbox —
ProfileExplorer.ProfilingrequiresTlbImp.exefor the DIA interop — so these were verified by inspection.