Skip to content

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

Closed

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

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Sep 15, 2022
  2. tannergooding commented on Sep 15, 2022

    @tannergooding
    Member

    Pretty sure this has already been fixed for RC2, but I will confirm first thing tomorrow.

    #74536 would be the likely fix that was done for it.

  3. hamarb123 commented on Sep 15, 2022

    @hamarb123
    ContributorAuthor

    Okay, so I would have to download a daily build to be able to test my actual code without this. Would the current daily build be new enough?

  4. tannergooding commented on Sep 15, 2022

    @tannergooding
    Member

    Yes, I expect the current daily build should contain the relevant fix.

  5. hamarb123 commented on Sep 15, 2022

    @hamarb123
    ContributorAuthor

    I've tested it, and it is fixed in the daily version, thanks!

    Also, (unrelated to this issue), is there a way to get the sdk installer not to do this (I assume it's removing the previous version)?
    image

  6. tannergooding commented on Sep 15, 2022

    @tannergooding
    Member

    I think @KathleenDollard or @baronfel would be the people to answer that.

    I'll close this issue since the issue is resolved in the latest daily build for .NET 7 RC2.

  7. baronfel commented on Sep 16, 2022

    @baronfel
    Member

    We typically only keep one version of the SDK from each 'feature band', meaning the last number's hundreth'-place. So depending on which 'channel' you've installed an SDK from (typically standalone installer MSI or VS are the main channels), if you install a newer version in the same feature band within that channel, the previous installation will be removed. So if you really wanted to make it happen, you could install a version of VS that included the preview you wanted, and install the standalone installer of the other version you wanted.

    Having said all of that, you can also use the dotnet-install scripts to install any version to any location at any time, setting the DOTNET_ROOT to point to that installed location.

  8. ghost locked as resolved and limited conversation to collaborators on Oct 16, 2022
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