ld.cxx: res and rc variables were accidentally swapped. Unswap them#34
Merged
Conversation
Signed-off-by: John Parent <john.parent@kitware.com>
scheibelp
reviewed
May 6, 2026
scheibelp
reviewed
May 6, 2026
Member
scheibelp
left a comment
There was a problem hiding this comment.
Functional change makes sense, but I think the debugging output should be removed before merging.
It seems like the linker is allowing the OS to cleanup the handle to the resource file we create to inject the Spack stage path into a given dll This means our cleanup is racey. Ensure it happens and is not racey using raii, falling back to a stderr warning message if we fail to clean vs an exception. Signed-off-by: John Parent <john.parent@kitware.com>
scheibelp
approved these changes
May 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We accidentally set res_file_name to use the rc base name and vis versa, which caused the wrong file to be cleaned at the wrong time, resulting in linker failures.
Further, we changed the generated res files to be produced in a temp dir vs the cwd, and added cleanup for these objects in a previous PR.
The cleanup for the RC file is file (resource compiler drops the handle seemingly immediately), but the cleanup for the resource file itself (.res) seems subject to a race condition where the linker allows the OS to cleanup the resource file handle, which is racey with our immediate clean attempt.
Instead, compose the resource file into its own class, and when that class goes out of scope, clean the resource file then and only then. If we still can't clean it for whatever reason, give a warning to stdout vs crashing the program with an exception.