Skip to content

Revert change to follow symlinks of dotnet host #115315

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 11 commits into from
Jun 7, 2025

Conversation

agocke
Copy link
Member

@agocke agocke commented May 5, 2025

#99576 changed the host to first
resolve symlinks before resolving the application directory. This means
that relative loads happen relative to the pointed-at file, not the
symbolic link. This was a breaking change made to match the symbolic
link behavior on all platforms.

Unfortunately, it seems a number of users have taken a dependency on the
Windows-specific behavior. This PR reverts the change and puts back in
place the old Windows behavior.

agocke added 2 commits May 5, 2025 15:39
dotnet#99576 changed the host to first
resolve symlinks before resolving the application directory. This means
that relative loads happen relative to the pointed-at file, not the
symbolic link. This was a breaking change made to match the symbolic
link behavior on all platforms.

Unfortunately, it seems a number of users have taken a dependency on the
Windows-specific behavior. This PR reverts the change and puts back in
place the old Windows behavior.
@Copilot Copilot AI review requested due to automatic review settings May 5, 2025 23:06
@ghost ghost added the area-Host label May 5, 2025
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 reverts the changes made in pull request #99576, restoring the Windows-specific symlink behavior for the dotnet host. The changes update native functions to use fullpath instead of realpath and update tests to expect failure when running behind symlinks.

  • Reverts use of pal::realpath to pal::fullpath in fxr_resolver.cpp and corehost.cpp.
  • Adjusts HostActivation.Tests in SymbolicLinks.cs to reflect the reverted behavior.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/native/corehost/fxr_resolver.cpp Replaces realpath with fullpath for handling app-relative dotnet roots.
src/native/corehost/corehost.cpp Replaces realpath with fullpath when resolving the host executable path.
src/installer/tests/HostActivation.Tests/SymbolicLinks.cs Updates test expectations to verify failure and appropriate error messages when symlink issues occur.
Comments suppressed due to low confidence (4)

src/installer/tests/HostActivation.Tests/SymbolicLinks.cs:40

  • Verify that the updated test expectation for failure when running the application behind a symlink accurately reflects the restored behavior.
.Should().Fail()

src/installer/tests/HostActivation.Tests/SymbolicLinks.cs:151

  • Double-check that the expected error message containing the dynamically generated path remains accurate and robust with potential directory structure changes.
.Should().Fail()

src/native/corehost/fxr_resolver.cpp:98

  • Ensure that using pal::fullpath in place of pal::realpath correctly reverts to the intended Windows-specific behavior as described in the PR.
if (search_app_relative && pal::fullpath(app_relative_dotnet_root))

src/native/corehost/corehost.cpp:131

  • Confirm that switching to pal::fullpath properly restores the expected executable path resolution for Windows.
if (!pal::get_own_executable_path(&host_path) || !pal::fullpath(&host_path))

Copy link
Contributor

Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.

@elinor-fung
Copy link
Member

Unfortunately, it seems a number of users have taken a dependency on the Windows-specific behavior.

Can we add a test case (with a comment about this) that constructs the symlink-ed apphost where the dependencies are not at the target, but are at the symlink?

@agocke
Copy link
Member Author

agocke commented May 12, 2025

Yes, great idea

@agocke
Copy link
Member Author

agocke commented May 13, 2025

@elinor-fung I believe this is ready for re-review


// This should succeed on all platforms, but for different reasons:
// * Windows: The apphost will look next to the symlink for the app dll and find the symlinked dll
// * Unix: The apphost will look next to the resolved apphost for the app dll and find the real thing
Copy link
Member

Choose a reason for hiding this comment

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

Maybe split this into separate cases? Basically so that the Windows case would fail without this revert.

  • Windows: app files do not exist at the target directory, only in the symlink directory
  • Unix: app files exist at the target directory

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure I understand the Windows case. Are you suggesting that in the Windows case we should separate out the files behind the symlink? It seems like that would be the only way it would fail without the revert.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, separate out just the apphost. I'm looking to hit the case that broke for folks - with the current test, Windows would still pass, since the files can still be resolved after following the apphost symlink since they are at the target.

For Windows, I'm thinking something like:

symlinked\
  app.exe -> target_app\app.exe
  app.dll -> app_deps\app.dll
  (other dependencies) -> app_deps\(other dependencies)

target_app\
  app.exe
  (no other files)

app_deps\
  app.dll
  (other dependencies)

Copy link
Member

@elinor-fung elinor-fung left a comment

Choose a reason for hiding this comment

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

Thanks!

@agocke
Copy link
Member Author

agocke commented Jun 3, 2025

/backport to release/9.0

Copy link
Contributor

github-actions bot commented Jun 3, 2025

Started backporting to release/9.0: https://github.com/dotnet/runtime/actions/runs/15407440566

@agocke
Copy link
Member Author

agocke commented Jun 3, 2025

/backport to release/9.0-staging

Copy link
Contributor

github-actions bot commented Jun 3, 2025

Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/15408385291

@agocke
Copy link
Member Author

agocke commented Jun 7, 2025

/ba-g failures are unrelated

@agocke agocke merged commit 7057719 into dotnet:main Jun 7, 2025
147 of 150 checks passed
@agocke agocke deleted the revert-realpath branch June 7, 2025 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants