Skip to content

Commit a1b972f

Browse files
giordanoKristofferC
authored andcommitted
Avoid stat-ing stdlib path if it's unreadable (#55992)
(cherry picked from commit 5d12c6d)
1 parent bc75cd1 commit a1b972f

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
@@ -3778,10 +3778,17 @@ end
37783778

37793779
# now check if this file's content hash has changed relative to its source files
37803780
if stalecheck
3781-
if !samefile(includes[1].filename, modpath) && !samefile(fixup_stdlib_path(includes[1].filename), modpath)
3782-
@debug "Rejecting cache file $cachefile because it is for file $(includes[1].filename) not file $modpath"
3783-
record_reason(reasons, "wrong source")
3784-
return true # cache file was compiled from a different path
3781+
if !samefile(includes[1].filename, modpath)
3782+
# In certain cases the path rewritten by `fixup_stdlib_path` may
3783+
# point to an unreadable directory, make sure we can `stat` the
3784+
# file before comparing it with `modpath`.
3785+
stdlib_path = fixup_stdlib_path(includes[1].filename)
3786+
if !(isreadable(stdlib_path) && samefile(stdlib_path, modpath))
3787+
!samefile(fixup_stdlib_path(includes[1].filename), modpath)
3788+
@debug "Rejecting cache file $cachefile because it is for file $(includes[1].filename) not file $modpath"
3789+
record_reason(reasons, "wrong source")
3790+
return true # cache file was compiled from a different path
3791+
end
37853792
end
37863793
for (modkey, req_modkey) in requires
37873794
# verify that `require(modkey, name(req_modkey))` ==> `req_modkey`

0 commit comments

Comments
 (0)