Regression in 0.11.3 -- NRE from ILProcessor.InsertBefore() #697

Closed
opened 2020-10-14 06:24:31 -05:00 by SteveGilham · 2 comments
SteveGilham commented 2020-10-14 06:24:31 -05:00 (Migrated from github.com)
System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Mono.Cecil
  StackTrace:
   at Mono.Cecil.Cil.InstructionCollection.ResolveInstructionOffset(InstructionOffset inputOffset, InstructionOffsetCache& cache) in C:\sources\cecil\Mono.Cecil.Cil\MethodBody.cs:line 412
   at Mono.Cecil.Cil.InstructionCollection.UpdateLocalScope(ScopeDebugInformation scope, Instruction removedInstruction, Instruction existingInstruction, InstructionOffsetCache& cache) in C:\sources\cecil\Mono.Cecil.Cil\MethodBody.cs:line 345
   at Mono.Cecil.Cil.InstructionCollection.UpdateLocalScope(ScopeDebugInformation scope, Instruction removedInstruction, Instruction existingInstruction, InstructionOffsetCache& cache) in C:\sources\cecil\Mono.Cecil.Cil\MethodBody.cs:line 356
   at Mono.Cecil.Cil.InstructionCollection.UpdateLocalScopes(Instruction removedInstruction, Instruction existingInstruction) in C:\sources\cecil\Mono.Cecil.Cil\MethodBody.cs:line 334
   at Mono.Collections.Generic.Collection`1.Insert(Int32 index, T item) in C:\sources\cecil\Mono.Collections.Generic\Collection.cs:line 149

Simple repro attached

Cecil.11.3.issue.zip

``` System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object. Source=Mono.Cecil StackTrace: at Mono.Cecil.Cil.InstructionCollection.ResolveInstructionOffset(InstructionOffset inputOffset, InstructionOffsetCache& cache) in C:\sources\cecil\Mono.Cecil.Cil\MethodBody.cs:line 412 at Mono.Cecil.Cil.InstructionCollection.UpdateLocalScope(ScopeDebugInformation scope, Instruction removedInstruction, Instruction existingInstruction, InstructionOffsetCache& cache) in C:\sources\cecil\Mono.Cecil.Cil\MethodBody.cs:line 345 at Mono.Cecil.Cil.InstructionCollection.UpdateLocalScope(ScopeDebugInformation scope, Instruction removedInstruction, Instruction existingInstruction, InstructionOffsetCache& cache) in C:\sources\cecil\Mono.Cecil.Cil\MethodBody.cs:line 356 at Mono.Cecil.Cil.InstructionCollection.UpdateLocalScopes(Instruction removedInstruction, Instruction existingInstruction) in C:\sources\cecil\Mono.Cecil.Cil\MethodBody.cs:line 334 at Mono.Collections.Generic.Collection`1.Insert(Int32 index, T item) in C:\sources\cecil\Mono.Collections.Generic\Collection.cs:line 149 ``` Simple repro attached [Cecil.11.3.issue.zip](https://github.com/jbevain/cecil/files/5377742/Cecil.11.3.issue.zip)
SteveGilham commented 2020-10-14 07:54:04 -05:00 (Migrated from github.com)

The null reference is the 7th of the 6 instructions in the method body; the initial access to the instructions through the Collection<Instruction> type with size less than capacity decays to a direct access to the internal Instruction[] which has length equal to the capacity.

FWIW, the assembly was built with an old Mono compiler, so advertises a code size of 14, hence the capacity of 7, for 6 instructions.

The null reference is the 7th of the 6 instructions in the method body; the initial access to the instructions through the `Collection<Instruction>` type with size less than capacity decays to a direct access to the internal `Instruction[]` which has length equal to the capacity. FWIW, the assembly was built with an old Mono compiler, so advertises a code size of 14, hence the capacity of 7, for 6 instructions.
jbevain commented 2020-10-15 12:01:53 -05:00 (Migrated from github.com)

Fixed in #698.

Fixed in #698.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-jbevain/cecil#697
No description provided.