Skip to content

[.NET 8] Some Symbol Entries in perf-%pid.map Are Truncated #102938

Closed

Description

@brianrob

Description

There is a regression in .NET 8 where symbols written to perf-%pid.map can be truncated. This means that profiling tools can display the wrong symbols after a profile has been captured on Linux.

Reproduction Steps

  1. Build the following application against .NET 8 on Linux:
using System;

public static class Program
{
    public static void Main(string[] args)
    {
        while(true)
        {
            Console.WriteLine();
        }
    }
}
  1. Run export COMPlus_PerfMapEnabled=1 to enable generation of perf-%pid.map files.
  2. Clear all perf-%pid.map files from /tmp.
  3. Run the application built in step 1 and then kill it via CTRL+C.
  4. Open /tmp/perf-%pid.map for the application. There is likely only one because we cleared out all the previous files.
  5. Search for ConsolePal::Writ(.

Expected behavior

An entry for System.ConsolePal::Write should exist. Here's an example correct entry:

0x7fb99c69d090 22a void [System.Console] System.ConsolePal::Write(class [System.Runtime]Microsoft.Win32.SafeHandles.SafeFileHandle,valuetype [System.Runtime]System.ReadOnlySpan`1<uint8>,bool)[MinOptJitted]

Actual behavior

An entry for System.ConsolePal::Writ exists, even though there is no such method. Here's an example entry:

0x7fb99c69d090 22a void [System.Console] System.ConsolePal::Writ(class [System.Runtime]Microsoft.Win32.SafeHandles.SafeFileHandle,valuetype [System.Runtime]System.ReadOnlySpan`1<uint8>,bool)[MinOptJitted]

Regression?

Yes. This is a regression from #81243.

This was subsequently fixed in .NET 9 via #98687. I have confirmed that applying this PR to .NET 8 fixes the problem. Requesting that we backport this change to .NET 8.

Known Workarounds

None.

Configuration

  • All versions of .NET 8.
  • All architectures.
  • Linux only.

Other information

No response

Activity

  1. ghost added
    needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
    on May 31, 2024
  2. brianrob commented on May 31, 2024

    @brianrob
    MemberAuthor

    @jakobbotsch, @janvorli what do you think about porting #98687 to .NET 8?

  3. added and removed
    needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
    on May 31, 2024
  4. janvorli commented on May 31, 2024

    @janvorli
    Member

    I think it is trivial enough to be safe to backport.

  5. brianrob commented on Jun 3, 2024

    @brianrob
    MemberAuthor

    Thanks @janvorli. Created backport PR #103003.

  6. brianrob commented on Jun 3, 2024

    @brianrob
    MemberAuthor

    Fixed via #103003.

  7. locked and limited conversation to collaborators on Jul 4, 2024
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