System.Runtime.MemoryFailPoint on .Net 8 throw an unexpected incorrect parameter exception instead of InsufficientMemoryException

Open
#118,383 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp

Research direction

Start with System.Runtime.MemoryFailPoint and the stack-traced MemFreeAfterAddress and CheckForFreeAddressSpace methods. Reproduce the supplied .NET 8 call with 250 MB and verify that the insufficient-memory path produces InsufficientMemoryException rather than an incorrect-parameter IOException; done means the reported behavior is corrected and the relevant behavior is covered by a regression test.

Written by the indexing model from the issue text.

Description

area-System.Runtime needs-further-triage

This issue has been moved from a ticket on Developer Community.


[severity:I'm unable to use this version]
We were using MemoryFailPoint in our .net framework application. Never have an issue with it.

We are now porting our app to .Net 8.
I feel that there is change within that class on how it work, because i don't get anymore the InsufficientMemoryException as expected.

It will throw the Incorrect parameter exception whether I put 200 or 2000 as memory to test.
This is how we call the function:

Try
    Dim x1 As New System.Runtime.MemoryFailPoint(250)
Catch ex As InsufficientMemoryException
    'Do stuff
End Try

This is the error I get:

System.IO.IOException: Paramètre incorrect.
at System.Runtime.MemoryFailPoint.MemFreeAfterAddress(Void* address, UInt64 size)
at System.Runtime.MemoryFailPoint.CheckForFreeAddressSpace(UInt64 size, Boolean shouldThrow)
at System.Runtime.MemoryFailPoint.. ctor(Int32 sizeInMegabytes)

So my questions:
First is there a patch for this in .Net 8 ?
Second, if not, am I suppose to catch the incorrect parameter Exception instead of the official one?

Thank for any help, and please forgive my english. :)


Original Comments
Feedback Bot on 30/07/2025, 08:09 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/runtime

All issues in dotnet/runtime

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.