dotnet / diagnostics

This repository contains the source code for various .NET Core runtime diagnostic tools and documents.
MIT License
1.18k stars 354 forks source link

[Regions] Avoid using allocation_started for USE_REGIONS #2483

Closed cshung closed 1 year ago

cshung commented 3 years ago

When USE_REGIONS is enabled, we don't have the field allocation_started defined on the generation class.

class generation
{
public:
    // Don't move these first two fields without adjusting the references
    // from the __asm in jitinterface.cpp.
    alloc_context   allocation_context;
    PTR_heap_segment start_segment;
#ifndef USE_REGIONS
    uint8_t*        allocation_start;
#endif //!USE_REGIONS
...
}

Sadly, it is still defined on DacpGenerationData as the struct cannot be changed. After https://github.com/dotnet/runtime/pull/56796 is merged, the field should always be 0.

Any code that depends on the value is wrong if the debuggee is run with USE_REGIONS enabled. Therefore we need to review all usage and see what we can do to fix them.

leculver commented 1 year ago

I'm closing this one as completed. All code within SOS and ClrMD only use allocation_start when dealing with segments (i.e. !defined(USE_REGIONS)). There's still a little code left in C++ SOS which has some GC logic, but that all will be removed when I'm done with my current work, but as of a few checkins ago we no longer incorrectly use allocation_start.