On Tue, 29 Aug 2023 00:16:46 GMT, Erik Joelsson <er...@openjdk.org> wrote:

> On Windows, when a directory exists in the "unix" root with the same name as 
> a directory in the "test" dir, fixpath will corrupt test arguments to jtreg 
> (and possibly other arguments as well). Fixpath sees a string like this:
> 
> test/jdk/foo
> 
> It looks for the first `/` and checks if the first element following that, 
> until the next `/`, is an existing directory in the unix filesystem root. In 
> this case, the reporter had a directory named "/jdk" which satisfies this 
> heuristic check. This makes fixpath assume that the `/jdk/foo` part is an 
> absolute unix path that needs to be rewritten to a Windows path.
> 
> My suggested fix is to look at the prefix part, "test" in this case, and see 
> if that itself is a valid path in the current working directory, as that 
> would indicate that the string is intended to be a relative path.
> 
> I think we also need to account for possible prefixes with `:` and `=` here 
> to handle a string like:
> 
> jtreg:test/jdk/foo
> 
> In that case we need to remove anything up to the last `:` before we try to 
> match it as a relative directory. (Same thing applies to `=`)
> 
> Changing the heuristics of fixpath is rather sensitive and risky. I would 
> appreciate help from people using Windows with trying this patch with some of 
> your regular workflows.

Some post-checkin reflections: I think this looks sane. In the end, we're doing 
a fair bit of guesswork to identify the paths, but this seems like a reasonable 
addition to the guessing machinery.

If I recall correctly, one thing that really made this even more messed-up was 
that on Windows, you could have like `buildtool.exe /pathOpt/jdk/src/...`, 
which needed to be rewritten as `buildtool.exe /pathOptC:\jdk\src...`. Hence 
the whole "prefix" dance. 

With this change, if the user has a directory named `pathOpt` in the unix root, 
we will do the wrong thing. Otoh, if that were the case, we'd be screwed anyway 
since there would be no way for us to separate a proper reference to files in 
/pathOpt and an argument beginning with `/pathOpt`. 

We have tried to minimize the risk of this by using `-` instead of `/` as 
option start marker on Windows as well as on unices, but there are likely 
places where a slash has slipped by, or where the command line is created by 
external tools outside our control.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/15461#issuecomment-1719170635

Reply via email to