Skip to content

SerializationGuard bloats the binary size on NAOT #87470

Closed

Description

@aromaa

Currently when calling Process.Start it brings the whole reflection stack with it even when the Switch.System.Runtime.Serialization.SerializationGuard.AllowProcessCreation is specified. This adds about 1MB to the final binary size.

The SerializationGuard seems to use reflection internally to retrieve the switch here which ends up rooting the reflection stack. It would be nice if the whole reflection guard concept would be possible to trim away on NAOT.

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Jun 13, 2023
  2. aromaa commented on Jun 13, 2023

    @aromaa
    ContributorAuthor

    Related #44369. Noticed it after I changed the title to be more general last minute. I'm more concerned about the Process.Start myself so this might be more actionable as a subset?

  3. danmoseley commented on Jun 13, 2023

    @danmoseley
    Contributor
  4. jkotas commented on Jun 13, 2023

    @jkotas
    Member

    It would be nice if the whole reflection guard concept would be possible to trim away on NAOT.

    Can we at least introduce a feature switch to allow people who do not want to pay for the serialization guard overheads to opt-out of it?

  5. stephentoub commented on Jun 13, 2023

    @stephentoub
    Member

    It would be nice if the whole reflection guard concept would be possible to trim away on NAOT.

    Can we at least introduce a feature switch to allow people who do not want to pay for the serialization guard overheads to opt-out of it?

    I'd be in favor of deleting it entirely, especially with BinaryFormatter disabled by default in most workloads and scheduled for extinction. Short of that, a feature switch in the meantime makes sense. Could we not just use the existing one for BinaryFormatter to also guard the guard?

  6. MichalStrehovsky commented on Jun 13, 2023

    @MichalStrehovsky
    Member

    Per #44369 (comment) this is also used in deserialization of DataTable so it's not BinaryFormatter only.

    Looks like users can configure DataSet/DataTable deserialization to be a binaryformatter-like security nightmare. I wonder whether that mode should also be obsoleted together with BinaryFormatter.

  7. added a commit that references this issue on Jul 31, 2023
    26fec69
  8. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Jul 31, 2023
  9. added a commit that references this issue on Aug 2, 2023
    ef900fa
  10. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Aug 2, 2023
  11. ghost removed
    untriagedNew issue has not been triaged by the area owner
    on Aug 2, 2023
  12. ghost locked as resolved and limited conversation to collaborators on Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions