ForNeVeR / ForNeVeR/Cesium

Improve IL verifiability

Open
#350 2 comments 0 reactions 0 assignees View on GitHub
area:compiler kind:feature status:help-wanted
Dominant language
C#
Stars
451
Forks
49
Avg merge
13h 59m
Merged PRs (30d)
6

Description

Currently, ILVerify reports several errors in our programs. Namely, considering `array/multidimensional.c` integration test:
```console
$ dotnet tool install --global dotnet-ilverify
$ pwsh Cesium.IntegrationTests/Run-Tests.ps1 -TestCaseName array/multidimensional.c
$ cd Cesium.IntegrationTests/bin
$ ilverify out_cs.exe -r "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\7.0.0\*.dll" -r .\Cesium.Runtime.dll
[IL]: Error [StackUnexpected]: [W:\Projects\Cesium\Cesium.IntegrationTests\bin\out_cs.exe : .::.cctor()][offset 0x00000006][found Native Int][expected Int32] Unexpected type on the stack.
[IL]: Error [Unverifiable]: [W:\Projects\Cesium\Cesium.IntegrationTests\bin\out_cs.exe : .::main(int32, uint8**)][offset 0x00000006] Instruction cannot be verified.
[IL]: Error [InitLocals]: [W:\Projects\Cesium\Cesium.IntegrationTests\bin\out_cs.exe : .::main(int32, uint8**)][offset 0x00000009] initlocals must be set for verifiable methods with one or more local variables.
[IL]: Error [UnmanagedPointer]: [W:\Projects\Cesium\Cesium.IntegrationTests\bin\out_cs.exe : .::main(int32, uint8**)][offset 0x00000009] Unmanaged pointers are not a verifiable type.
[IL]: Error [StackByRef]: [W:\Projects\Cesium\Cesium.IntegrationTests\bin\out_cs.exe : .::main(int32, uint8**)][offset 0x00000020][found Native Int] Expected ByRef on the stack.
[IL]: Error [StackUnexpected]: [W:\Projects\Cesium\Cesium.IntegrationTests\bin\out_cs.exe : .::(string[])][offset 0x00000002][found Native Int][expected Int32] Unexpected type on the stack.
[IL]: Error [InitLocals]: [W:\Projects\Cesium\Cesium.IntegrationTests\bin\out_cs.exe : .::(string[])][offset 0x0000000A] initlocals must be set for verifiable methods with one or more local variables.
[IL]: Error [InitLocals]: [W:\Projects\Cesium\Cesium.IntegrationTests\bin\out_cs.exe : .::(string[])][offset 0x00000012] initlocals must be set for verifiable methods with one or more local variables.
[IL]: Error [InitLocals]: [W:\Projects\Cesium\Cesium.IntegrationTests\bin\out_cs.exe : .::(string[])][offset 0x00000013] initlocals must be set for verifiable methods with one or more local variables.
[IL]: Error [InitLocals]: [W:\Projects\Cesium\Cesium.IntegrationTests\bin\out_cs.exe : .::(string[])][offset 0x0000001A] initlocals must be set for verifiable methods with one or more local variables.
[IL]: Error [InitLocals]: [W:\Projects\Cesium\Cesium.IntegrationTests\bin\out_cs.exe : .::(string[])][offset 0x0000001B] initlocals must be set for verifiable methods with one or more local variables.
[IL]: Error [InitLocals]: [W:\Projects\Cesium\Cesium.IntegrationTests\bin\out_cs.exe : .::(string[])][offset 0x0000001D] initlocals must be set for verifiable methods with one or more local variables.
[IL]: Error [StackUnexpected]: [W:\Projects\Cesium\Cesium.IntegrationTests\bin\out_cs.exe : .::(string[])][offset 0x00000024][found address of 'uint8*'][expected Native Int] Unexpected type on the stack.
[IL]: Error [InitLocals]: [W:\Projects\Cesium\Cesium.IntegrationTests\bin\out_cs.exe : .::(string[])][offset 0x00000035] initlocals must be set for verifiable methods with one or more local variables.
[IL]: Error [InitLocals]: [W:\Projects\Cesium\Cesium.IntegrationTests\bin\out_cs.exe : .::(string[])][offset 0x0000003C] initlocals must be set for verifiable methods with one or more local variables.
15 Error(s) Verifying W:\Projects\Cesium\Cesium.IntegrationTests\bin\out_cs.exe
```

We should investigate whether these issues are acceptable or not.

They may be reason for the `multidimensional.c` test failing [one time](https://github.com/ForNeVeR/Cesium/actions/runs/3456803938/jobs/5769804237#step:6:485).

Contributor guide

Open the contributing guide

Research direction

Start with the array/multidimensional.c integration test and Cesium.IntegrationTests/Run-Tests.ps1, then reproduce the output with dotnet-ilverify as shown. Review the reported verification errors and the linked intermittent test failure to determine whether they are acceptable. Done means the verifiability issue has a documented resolution and the integration test behavior is addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, csharp
Domain
compilers, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.