Skip to content

Avoid double disposal of terminal logger #49969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2025
Merged

Conversation

jjonescz
Copy link
Member

@jjonescz jjonescz commented Jul 28, 2025

Fixes a regression introduced in #49841 - dotnet run file.cs results in "Unhandled exception: The CancellationTokenSource has been disposed." It only appears when using the terminal logger, hence no tests catch it (and I don't think it can be tested, see dotnet/msbuild#12237).

@jjonescz jjonescz added the Area-run-file Items related to the "dotnet run <file>" effort label Jul 28, 2025
@jjonescz
Copy link
Member Author

/backport to release/10.0.1xx-preview7

Copy link
Contributor

Started backporting to release/10.0.1xx-preview7: https://github.com/dotnet/sdk/actions/runs/16571305334

@jjonescz jjonescz marked this pull request as ready for review July 28, 2025 14:24
@jjonescz jjonescz requested review from Copilot and a team July 28, 2025 14:24
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a regression that caused an "Unhandled exception: The CancellationTokenSource has been disposed." error when running dotnet run file.cs with the terminal logger. The fix prevents double disposal of the console logger by nulling the reference after disposal and adding a null check before calling Shutdown().

Key changes:

  • Adds null assignment to avoid double disposal
  • Adds null-conditional operator to prevent calling Shutdown() on disposed logger

@MiYanni MiYanni merged commit c3a4895 into dotnet:main Jul 28, 2025
30 checks passed
@jjonescz jjonescz deleted the sprint-tl branch August 12, 2025 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-run-file Items related to the "dotnet run <file>" effort
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants