You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Removing an instruction from method body currently doesn't update the attached debug information's local scope ranges. This can lead to incorrect or even corrupt debug information.
An example is removing instructions from the end of the method eventually removing enough so that the last local scope in the method should be removed. When such method is written the associated PDB still has the last local scope in it, but now its start offset points after the method body end. Depending on the reader this can lead to either confusion or plain crashes.
For example the PDB2PDB tool (which uses System.Reflection.Metadata reader for the portable PDB) will either fail to read or fail to process such PDB.
InstructionCollection.OnRemove already contains logic to update sequence points in the debug info accordingly. This can be updated to handle local scopes as well.
More complex problem is how to handle OnAdd and OnInsert. If the instruction is being inserted on a local scope boundary it's unclear to which scope it should fall into. The implemented behavior should works such that ILProcessor.Replace which internally inserts after and removes ends up updating the local scopes correctly (so that the replaced instruction ends up in the same local scope and the start/end of local scopes don't move around).
Removing an instruction from method body currently doesn't update the attached debug information's local scope ranges. This can lead to incorrect or even corrupt debug information.
An example is removing instructions from the end of the method eventually removing enough so that the last local scope in the method should be removed. When such method is written the associated PDB still has the last local scope in it, but now its start offset points after the method body end. Depending on the reader this can lead to either confusion or plain crashes.
For example the PDB2PDB tool (which uses System.Reflection.Metadata reader for the portable PDB) will either fail to read or fail to process such PDB.
InstructionCollection.OnRemove
already contains logic to update sequence points in the debug info accordingly. This can be updated to handle local scopes as well.More complex problem is how to handle
OnAdd
andOnInsert
. If the instruction is being inserted on a local scope boundary it's unclear to which scope it should fall into. The implemented behavior should works such thatILProcessor.Replace
which internally inserts after and removes ends up updating the local scopes correctly (so that the replaced instruction ends up in the same local scope and the start/end of local scopes don't move around).Originally found in dotnet/linker#1267
I plan to work on a PR for this unless somebody wants to pick it up first.
The text was updated successfully, but these errors were encountered: