Skip to content

Empty array allocated on the Frozen Heap for a Collectible type? #100437

Closed

Description

@xoofx

Hello folks,

Apologies, it's not a fully reproducible bug as we haven't tried yet to reproduce it with a simpler sample, but we have a suspicion.

We are investigating an error where we have the GC marking of frozen objects gc_heap::mark_ro_segments()that is crashing.

One place that we are curious about is in TryAllocateFrozenSzArray:

if (pArrayMT->ContainsPointers() && cElements > 0)
{
// For arrays with GC pointers we can only work with empty arrays
return NULL;
}

Where it seems that we could allow to allocate an empty array for collectible MethodTable in the Frozen heap. Shouldn't it be something like this instead?

    if (pArrayMT->Collectible() || (pArrayMT->ContainsPointers() && cElements > 0))
    {
        // For arrays with GC pointers we can only work with empty arrays
        return NULL;
    }

Before we investigate this further, any thoughts?

cc: @EgorBo

Activity

  1. ghost added
    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
    on Mar 29, 2024
  2. dotnet-policy-service commented on Mar 29, 2024

    @dotnet-policy-service
    Contributor

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

  3. jkotas commented on Mar 29, 2024

    @jkotas
    Member

    Before we investigate this further, any thoughts?

    Yes, this looks like a bug. Could you please submit a PR with the fix?

  4. xoofx commented on Mar 29, 2024

    @xoofx
    MemberAuthor

    Yes, this looks like a bug. Could you please submit a PR with the fix?

    Sure!

  5. jkotas commented on Mar 29, 2024

    @jkotas
    Member

    There is CORJIT_FLAG_FROZEN_ALLOC_ALLOWED that handles most cases, but it does not cover shared generics. The shared generic code may have CORJIT_FLAG_FROZEN_ALLOC_ALLOWED set, but the actual instantiation can be collectible. I think you should be able to reproduce the crash using a pattern like this.

  6. xoofx commented on Mar 29, 2024

    @xoofx
    MemberAuthor

    Created PR #100444. We have tested a similar fix in our own fork, and it seems to be fixing our issues.

  7. added this to the 9.0.0 milestone on Mar 29, 2024
  8. locked and limited conversation to collaborators on May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions