Skip to content

Remove PSEUDORANDOM_NOP_INSERTION and associated code #54242

Closed

Description

@SingleAccretion

While browsing the Jit's source, I noticed this comment:

// All code generated by this function must not contain the randomly-inserted NOPs
// that we insert to inhibit JIT spraying in partial trust scenarios.
// The PINVOKE_PROLOG op signals this to the code generator/emitter.

And the corresponding #define PSEUDORANDOM_NOP_INSERTION, which is now disabled:

/*****************************************************************************/

// The pseudorandom nop insertion is not necessary for current scenarios
// #define PSEUDORANDOM_NOP_INSERTION

/*****************************************************************************/

So the question is as in the header: do we foresee this being a useful mitigation to have in the future, and if not, should the code supporting it be removed?

cc @jkotas, @BruceForstall

category:implementation
theme:codegen
skill-level:beginner
cost:small
impact:small

Activity

  1. ghost added
    untriaged
    on Jun 15, 2021
  2. jkotas commented on Jun 15, 2021

    @jkotas
    Member

    It should be fine to clean this up. This mitigation was relevant for partial trust that we no longer care about and that is not comming back.

  3. added
    area-CodeGen-coreclr
    help wanted
    on Jun 15, 2021
  4. removed
    untriaged
    on Jun 16, 2021
  5. added this to the Future milestone on Jun 16, 2021
  6. changed the title [-]Should `PSEUDORANDOM_NOP_INSERTION` and associated code be kept?[/-] [+]Remove `PSEUDORANDOM_NOP_INSERTION` and associated code[/+] on Jun 16, 2021
  7. BruceForstall commented on Jun 16, 2021

    @BruceForstall
    Contributor

    I went ahead and re-titled this from a question to something that can track actually doing the removal.

  8. ayousuf23 commented on Jun 22, 2021

    @ayousuf23
    Contributor

    @SingleAccretion How much code is there to remove?

  9. SingleAccretion commented on Jun 22, 2021

    @SingleAccretion
    ContributorAuthor

    @ayousuf23 it is a bit tricky to quantify, because not all dead code is under the #ifdef, and I did not look too deeply into it. Does not look like there is that much though, quickly searching for the ifdef itself, GT_PINVOKE_PROLOG, GT_PINVOKE_EPILOG and GT_EMITNOP.

  10. DylanGTech commented on Jul 29, 2021

    @DylanGTech

    This doesn't look too difficult to do, as you stated, @SingleAccretion, it's a matter of searching and removing code that is no longer used. I can give this a go.

  11. added
    in-pr
    on Mar 29, 2026
  12. locked and limited conversation to collaborators on Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrhelp wantedin-pr

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions