Skip to content

Conversation

@barucden
Copy link
Contributor

This commit prevents stack overflow when safe_realpath is called with
a non-existing path that does not start with a /, such as

"D:\ProjectA" (on a Windows machine without drive D:)
""
"non-existing-path"

Resolves #3085

This commit prevents stack overflow when `safe_realpath` is called with
a non-existing path that does not start with a `/`, such as

    "D:\ProjectA" (on a Windows machine without drive D:)
    ""
    "non-existing-path"

Resolves JuliaLang#3085
@fredrikekre fredrikekre merged commit f092729 into JuliaLang:master May 19, 2022
@barucden barucden deleted the safe_realpath branch May 19, 2022 09:27
KristofferC pushed a commit that referenced this pull request May 24, 2022
This commit prevents stack overflow when `safe_realpath` is called with a non-existing
path that does not start with a `/`, such as `D:\ProjectA` (on a Windows machine without
drive `D:`) or `non-existing-path`, fixes #3085.

(cherry picked from commit f092729)
@KristofferC KristofferC mentioned this pull request May 24, 2022
11 tasks
visr added a commit to visr/Pkg.jl that referenced this pull request Jul 7, 2025
Fixes JuliaLang#3085

That issue was already closed by JuliaLang#3087 but I still ran into the same issue, it seems the fix was wrong.

The stack overflow can still be triggered on Windows by

```jl
using Pkg: safe_realpath
safe_realpath("some-non-existing-drive:")
```

It keeps on recursing trying to make it smaller with `splitdir`, but it can't. We know we cannot make it smaller if the returned "filename" is empty.

On Linux we have:
```jl
julia> splitdir("/")
("/", "")
```

On Windows:
```jl
julia> splitdir("C://")
("C:/", "")
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stackoverflow if manifest contains references to removed drive

3 participants