Skip to content

Commit 5d12c6d

Browse files
authored
Avoid stat-ing stdlib path if it's unreadable (#55992)
1 parent 096c1d2 commit 5d12c6d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

base/loading.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3864,10 +3864,17 @@ end
38643864

38653865
# now check if this file's content hash has changed relative to its source files
38663866
if stalecheck
3867-
if !samefile(includes[1].filename, modpath) && !samefile(fixup_stdlib_path(includes[1].filename), modpath)
3868-
@debug "Rejecting cache file $cachefile because it is for file $(includes[1].filename) not file $modpath"
3869-
record_reason(reasons, "wrong source")
3870-
return true # cache file was compiled from a different path
3867+
if !samefile(includes[1].filename, modpath)
3868+
# In certain cases the path rewritten by `fixup_stdlib_path` may
3869+
# point to an unreadable directory, make sure we can `stat` the
3870+
# file before comparing it with `modpath`.
3871+
stdlib_path = fixup_stdlib_path(includes[1].filename)
3872+
if !(isreadable(stdlib_path) && samefile(stdlib_path, modpath))
3873+
!samefile(fixup_stdlib_path(includes[1].filename), modpath)
3874+
@debug "Rejecting cache file $cachefile because it is for file $(includes[1].filename) not file $modpath"
3875+
record_reason(reasons, "wrong source")
3876+
return true # cache file was compiled from a different path
3877+
end
38713878
end
38723879
for (modkey, req_modkey) in requires
38733880
# verify that `require(modkey, name(req_modkey))` ==> `req_modkey`

0 commit comments

Comments
 (0)