Skip to content

Commit 3f2bfcd

Browse files
committed
Avoid stat-ing stdlib path if it's unreadable
1 parent 204b0b9 commit 3f2bfcd

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

base/loading.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3115,9 +3115,16 @@ end
31153115

31163116
# now check if this file is fresh relative to its source files
31173117
if !skip_timecheck
3118-
if !samefile(includes[1].filename, modpath) && !samefile(fixup_stdlib_path(includes[1].filename), modpath)
3119-
@debug "Rejecting cache file $cachefile because it is for file $(includes[1].filename) not file $modpath"
3120-
return true # cache file was compiled from a different path
3118+
if !samefile(includes[1].filename, modpath)
3119+
stdlib_path = fixup_stdlib_path(includes[1].filename)
3120+
# In certain cases the path rewritten by `fixup_stdlib_path` may
3121+
# point to an unreadable directory, make sure we can `stat` the
3122+
# file before comparing it with `modpath`.
3123+
isreadable = iszero(@ccall jl_fs_access(stdlib_path::Cstring, 0x04::Cint)::Cint)
3124+
if isreadable !samefile(stdlib_path, modpath)
3125+
@debug "Rejecting cache file $cachefile because it is for file $(includes[1].filename) not file $modpath"
3126+
return true # cache file was compiled from a different path
3127+
end
31213128
end
31223129
for (modkey, req_modkey) in requires
31233130
# verify that `require(modkey, name(req_modkey))` ==> `req_modkey`

0 commit comments

Comments
 (0)