<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/investigating-an-invalidprogramexception-from-a-memory-dump-part-2-of-3--p5gpkcbcg" -->

---
title: Investigating an InvalidProgramException from a memory...
description: A deep technical walkthrough of debugging a .NET InvalidProgramException caused by a bug in the Datadog profiler's IL rewriting, continuing from part one of a...
canonical: https://daily.dev/posts/investigating-an-invalidprogramexception-from-a-memory-dump-part-2-of-3--p5gpkcbcg
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Investigating an InvalidProgramException from a memory dump (part 2 of 3) | daily.dev
og:description: A deep technical walkthrough of debugging a .NET InvalidProgramException caused by a bug in the Datadog profiler's IL rewriting, continuing from part one of a...
og:url: https://daily.dev/posts/investigating-an-invalidprogramexception-from-a-memory-dump-part-2-of-3--p5gpkcbcg
og:image: https://api.daily.dev/og/posts/p5gPkcBcG.png
og:image:alt: Investigating an InvalidProgramException from a memory dump (part 2 of 3)
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Investigating an InvalidProgramException from a memory dump (part 2 of 3)

**[Kevin Gosse \(minidump.net\)](https://daily.dev/sources/minidump)** · 14 min read · 0 upvotes · 0 comments

## Summary

A deep technical walkthrough of debugging a .NET InvalidProgramException caused by a bug in the Datadog profiler's IL rewriting, continuing from part one of a three-part series. The author locates the MethodDesc for the async state-machine's MoveNext method using dotnet-dump commands, discovers the JIT discarded the rewritten IL after failing to compile it, then reverse-engineers the CoreCLR source and disassembles Module::SetDynamicIL using gdb to find the internal m_debuggerSpecificData structure offset. Using LLDB memory reads on a memory dump, the author manually walks CoreCLR's internal hash table structures to locate and verify the raw rewritten IL bytes by matching a known LocalVarSig token value.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://minidump.net/investigating-an-invalidprogramexception-from-a-memory-dump-part-2-of-3-daaecd8f3cf4>

## Questions this post answers

### How can I find the dynamically rewritten IL for a method in a .NET memory dump when dumpil shows the original IL?

Disassemble Module::SetDynamicIL in libcoreclr.so with gdb to find the offset of m_debuggerSpecificData.m_pDynamicILBlobTable within the Module object, then read that memory region with LLDB to walk the internal hash table (DynamicILBlobTable) and locate the entry matching the target method's token, which points to the raw rewritten IL bytes.

_daily.dev surfaces deep debugging writeups like this for engineers chasing elusive runtime bugs._

### Why would dotnet-dump's dumpil command show the original IL instead of profiler-rewritten IL for a method that threw InvalidProgramException?

The method is marked as not jitted because the JIT attempted to compile the profiler's rewritten IL, failed with InvalidProgramException, and discarded the rewritten bytes, leaving only the original IL retrievable through dumpil. The rewritten IL still exists temporarily in the module's internal DynamicILBlobTable structure in memory, even though dumpil cannot access it.

_daily.dev helps .NET engineers track down obscure profiler and JIT debugging techniques._

## Similar posts on daily.dev

- [Creating a memory dump in C\#](https://daily.dev/posts/creating-a-memory-dump-in-c--torykruun) · .NET Blog · 16 upvotes · 0 comments
- [What Actually Changed Inside the .NET 11 JIT Compiler — Daily DevOps & .NET](https://daily.dev/posts/what-actually-changed-inside-the-net-11-jit-compiler-daily-devops-net-s6qx7oe7d) · Daily DevOps & .NET · 27 upvotes · 4 comments
- [Today I will… debug a production crash](https://daily.dev/posts/today-i-will-debug-a-production-crash-oix9ikedw) · Visual Studio Blog · 11 upvotes · 1 comments

---

Tags: [#.net](https://daily.dev/tags/.net), [#assembly](https://daily.dev/tags/assembly)

[View this post on daily.dev](https://daily.dev/posts/investigating-an-invalidprogramexception-from-a-memory-dump-part-2-of-3--p5gpkcbcg)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Investigating an InvalidProgramException from a memory dump (part 2 of 3)","url":"https://daily.dev/posts/investigating-an-invalidprogramexception-from-a-memory-dump-part-2-of-3--p5gpkcbcg","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/investigating-an-invalidprogramexception-from-a-memory-dump-part-2-of-3--p5gpkcbcg"},"datePublished":"2026-10-04T13:05:18.915Z","dateModified":"2026-10-04T13:09:35.122Z","description":"A deep technical walkthrough of debugging a .NET InvalidProgramException caused by a bug in the Datadog profiler's IL rewriting, continuing from part one of a...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/23c0a4d5ab79f2eb60390cd2fc6a5db9?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/23c0a4d5ab79f2eb60390cd2fc6a5db9?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Kevin Gosse (minidump.net)","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Kevin Gosse (minidump.net)","logo":"https://media.daily.dev/image/upload/s--8KHn1aFB--/f_auto,q_auto/v1791119046/logos/minidump?_a=BAMAMicg0","url":"https://daily.dev/sources/minidump"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/investigating-an-invalidprogramexception-from-a-memory-dump-part-2-of-3--p5gpkcbcg","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":".net,assembly","timeRequired":"PT14M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Kevin Gosse (minidump.net)","item":"https://daily.dev/sources/minidump"},{"@type":"ListItem","position":3,"name":"Investigating an InvalidProgramException from a memory dump (part 2 of 3)"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/investigating-an-invalidprogramexception-from-a-memory-dump-part-2-of-3--p5gpkcbcg#faq","mainEntity":[{"@type":"Question","name":"How can I find the dynamically rewritten IL for a method in a .NET memory dump when dumpil shows the original IL?","acceptedAnswer":{"@type":"Answer","text":"Disassemble Module::SetDynamicIL in libcoreclr.so with gdb to find the offset of m_debuggerSpecificData.m_pDynamicILBlobTable within the Module object, then read that memory region with LLDB to walk the internal hash table (DynamicILBlobTable) and locate the entry matching the target method's token, which points to the raw rewritten IL bytes. daily.dev surfaces deep debugging writeups like this for engineers chasing elusive runtime bugs."}},{"@type":"Question","name":"Why would dotnet-dump's dumpil command show the original IL instead of profiler-rewritten IL for a method that threw InvalidProgramException?","acceptedAnswer":{"@type":"Answer","text":"The method is marked as not jitted because the JIT attempted to compile the profiler's rewritten IL, failed with InvalidProgramException, and discarded the rewritten bytes, leaving only the original IL retrievable through dumpil. The rewritten IL still exists temporarily in the module's internal DynamicILBlobTable structure in memory, even though dumpil cannot access it. daily.dev helps .NET engineers track down obscure profiler and JIT debugging techniques."}}]}
```

