Skip to content

Fix CilPurityClassifier misclassifying several opcodes - #155

Merged
Washi1337 merged 2 commits into
Washi1337:masterfrom
wondercrash:fix/cilpurityclassifier-bugs
Feb 26, 2026
Merged

Fix CilPurityClassifier misclassifying several opcodes#155
Washi1337 merged 2 commits into
Washi1337:masterfrom
wondercrash:fix/cilpurityclassifier-bugs

Conversation

@wondercrash

@wondercrash wondercrash commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

Added missing cases to ClassifyInlineNone :

  • stind.r4 and stind.ref were missing
  • cpblk and initblk are pointer writes
  • throw and rethrow should be impure
  • localloc is impure since its similar to newarr (allocates and pushes a pointer)

Added cpobj, initobj, and stobj to ClassifyInlineType as pointer writes

Using DefaultTypeAccessPurity for stelem doesn't really make sense to me since stelem doesn't really access a type, it just uses it to get the size of the element I believe.

case CilCode.Stelem:
return ArrayWritePurity | DefaultTypeAccessPurity;

dnlib's CilPurityClassifier was outdated so I ported over AsmResolver's along with the changes.

I wouldn't mind feedback on these changes though

@Washi1337

Copy link
Copy Markdown
Owner

Interesting, I was under the impression ldelem/stelem/cpobj/etc would trigger a type class constructor call (and thus would be a type access purity), but it seems not to be the case (In fact, on Mono, not even <Module>::.cctor is necessarily called, even when the type is loaded from an external DLL).

Thanks

@Washi1337
Washi1337 merged commit cfe5e50 into Washi1337:master Feb 26, 2026
2 checks passed
@wondercrash
wondercrash deleted the fix/cilpurityclassifier-bugs branch February 26, 2026 19:28
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.

2 participants