Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

object.GetType needs to have an exception set #63553

Closed
SingleAccretion opened this issue Jan 9, 2022 · 2 comments · Fixed by #64106
Closed

object.GetType needs to have an exception set #63553

SingleAccretion opened this issue Jan 9, 2022 · 2 comments · Fixed by #64106
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI bug
Milestone

Comments

@SingleAccretion
Copy link
Contributor

SingleAccretion commented Jan 9, 2022

Reproduction:

using System;
using System.Runtime.CompilerServices;

Console.WriteLine(Problem(null, 0));

[MethodImpl(MethodImplOptions.NoInlining  | MethodImplOptions.AggressiveOptimization)]
static bool Problem(object a, int i)
{
    var fls = false;
    var c1 = i == 0;
    var c2 = c1;

    if (((a.GetType() == a) & fls) | (i == 0))
    {
        return true;
    }

    return c2;
}

Expected result: NullReferenceException thrown.
Actual result: true printed.

Cause: the GetType intrinsic needs to have an exception set.

Waiting on the refactoring in #63539 to get merged to submit the fix.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Jan 9, 2022
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@SingleAccretion SingleAccretion added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI bug and removed untriaged New issue has not been triaged by the area owner labels Jan 9, 2022
@ghost
Copy link

ghost commented Jan 9, 2022

Tagging subscribers to this area: @JulieLeeMSFT
See info in area-owners.md if you want to be subscribed.

Issue Details

Reproduction:

using System;
using System.Runtime.CompilerServices;

Console.WriteLine(Problem(null, 0));

[MethodImpl(MethodImplOptions.NoInlining  | MethodImplOptions.AggressiveOptimization)]
static bool Problem(object a, int i)
{
    var fls = false;
    var c1 = i == 0;
    var c2 = c1;

    if (((a.GetType() == a) & fls) | (i == 0))
    {
        return true;
    }

    return c2;
}

Expected result: NullReferenceException thrown.
Actual result: true printed.

Cause: the GetType intrinsic needs to have an exception set.

Waiting on the refactoring in #63539 to get merged for the fix.

Author: SingleAccretion
Assignees: -
Labels:

bug, area-CodeGen-coreclr

Milestone: -

@SingleAccretion SingleAccretion added this to the 7.0.0 milestone Jan 9, 2022
@SingleAccretion SingleAccretion self-assigned this Jan 9, 2022
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jan 21, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jan 25, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Feb 25, 2022
@SingleAccretion SingleAccretion removed their assignment May 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant