Skip to content

System.AccessViolationException: Int128 ToString invalid memory reads and string interpolation crash #75656

Description

@hamarb123

Description

When I to .ToString() on my Int128, it reads out memory and then crashes.
When I do string interpolation on my Int128, it throws an exception and crashes.
Clearly, this is not intended functionality.

Reproduction Steps

  1. Run
Console.WriteLine(new Int128(18446744073709551613, 18446744073709551604).ToString());
  1. Run
Console.WriteLine($"A={new Int128(18446744073709551613, 18446744073709551604)})");

(This is literally my whole program now because I wanted to make sure it wasn't something else)

Expected behavior

Prints a number and doesn't crash ;)

Actual behavior

  1. Prints random memory and crashes
    image

  2. Crashes
    image

Regression?

No response

Known Workarounds

No response

Configuration

.NET 7 RC 1
Windows 10 x64 v10.0.19044.1949
Running in Debug mode

Also tested on macOS 12.6 x64 with .NET 7 Preview 7, got slightly different output (below):

  1. image
  2. image

Other information

It's probably missing a \0 at the end based on that ridiculous console output. idk. Also unsure if the string interpolation one has a secondary issue as well or not.

Edit: it (above) being one of the helper method that converts to a string. This could be why since it may just keep reading random memory when constructing the string until it hits a \0 char (ie. 2x 0 bytes - low chance hence why I see AVEs instead) or an AVE/NRE.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions