Skip to content

Bugfix :: Fix codegen runtime crashes: TypeLoadException, InvalidProgramException, stack corruption#19338

Merged
T-Gro merged 7 commits intomainfrom
codegen/fix-runtime-crashes
Apr 14, 2026
Merged

Bugfix :: Fix codegen runtime crashes: TypeLoadException, InvalidProgramException, stack corruption#19338
T-Gro merged 7 commits intomainfrom
codegen/fix-runtime-crashes

Conversation

@T-Gro
Copy link
Copy Markdown
Member

@T-Gro T-Gro commented Feb 20, 2026

Fixes runtime exceptions caused by incorrect IL emitted for valid F# programs.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 20, 2026

✅ No release notes required

@T-Gro T-Gro force-pushed the codegen/fix-runtime-crashes branch 5 times, most recently from 3616853 to 9549f87 Compare February 20, 2026 17:32
@T-Gro T-Gro marked this pull request as ready for review March 6, 2026 18:32
@T-Gro T-Gro requested a review from a team as a code owner March 6, 2026 18:32
@T-Gro T-Gro changed the title WIP :: Bugfix :: Fix codegen runtime crashes: TypeLoadException, InvalidProgramException, stack corruption Bugfix :: Fix codegen runtime crashes: TypeLoadException, InvalidProgramException, stack corruption Mar 6, 2026
Comment thread src/Compiler/CodeGen/IlxGen.fs Outdated
@github-project-automation github-project-automation bot moved this from New to In Progress in F# Compiler and Tooling Mar 20, 2026
@T-Gro T-Gro force-pushed the codegen/fix-runtime-crashes branch 2 times, most recently from 08b170a to 84eaa60 Compare March 31, 2026 09:55
@T-Gro T-Gro force-pushed the codegen/fix-runtime-crashes branch from 84eaa60 to f4957a8 Compare April 10, 2026 10:07
T-Gro and others added 6 commits April 13, 2026 12:56
…k corruption

Fix 6 codegen bugs that cause hard crashes or invalid IL:
- #11132: voidptr delegate TypeLoadException
- #13447: tail. + localloc stack corruption
- #14492: inline constraints TypeLoadException in Release
- #14508: nativeptr in interfaces TypeLoadException
- #18319: literal upcast missing box instruction
- #18956: decimal literal InvalidProgramException in Debug

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mark Issue_13447_TailInstructionCorruption and Issue_11132_VoidptrDelegate
tests with FactForNETCOREAPP to skip on net472 Desktop test runs.

- Issue_13447 uses Span<byte> which is not available on net472
- Issue_11132 uses voidptr in closure generic args which requires
  netcore runtime support

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address PR review feedback from abonie:
- Extract shared slotSigRequiresNativePtrRewrite helper to detect
  nativeptr<'T> with concrete class type params in both params and
  return types
- GetMethodSpecForMemberVal now selectively rewrites param types
  (not just return types) when interface slot has nativeptr<ClassTypar>
- GenActualSlotsig refactored to use the shared helper, removing
  the containsNativePtrWithTypar wrapper
- Add 4 new runtime tests covering nativeptr in interface params

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@T-Gro T-Gro force-pushed the codegen/fix-runtime-crashes branch from f4957a8 to 8a022ea Compare April 13, 2026 11:16
The test for issue #14492 (same-assembly inline with constrained generics)
was embedded inside Issue_14508_NativeptrMultipleParams via variable shadowing.
Extract it into Issue_14492_SameAssemblyInline for proper test identification.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@T-Gro T-Gro requested a review from abonie April 14, 2026 08:06
@T-Gro T-Gro enabled auto-merge (squash) April 14, 2026 14:25
@T-Gro T-Gro merged commit 03feed2 into main Apr 14, 2026
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment